diff --git a/img/bg.jpg b/img/bg/1.jpg similarity index 100% rename from img/bg.jpg rename to img/bg/1.jpg diff --git a/img/bg/2.jpg b/img/bg/2.jpg new file mode 100644 index 0000000..834f644 Binary files /dev/null and b/img/bg/2.jpg differ diff --git a/script.js b/script.js index 1115e87..448f82e 100644 --- a/script.js +++ b/script.js @@ -2,11 +2,19 @@ let currentLang = "zh"; let data, i18n; document.addEventListener("DOMContentLoaded", () => { + setRandomBackground(); loadData("data.json", loadBlockchainOptions); changeLanguage(currentLang); updateCopyrightYear(); }); +function setRandomBackground() { + const images = ['1.jpg', '2.jpg']; + const randomIndex = Math.floor(Math.random() * images.length); + const selectedImage = images[randomIndex]; + document.body.style.backgroundImage = `url('img/bg/${selectedImage}')`; +} + function updateCopyrightYear() { const currentYear = new Date().getFullYear(); let copyrightText; diff --git a/styles.css b/styles.css index b2aa9cd..ff627d6 100644 --- a/styles.css +++ b/styles.css @@ -1,7 +1,6 @@ body { font-family: Microsoft YaHei; font-weight: bold; - background-image: url("img/bg.jpg"); background-size: cover; background-position: center; background-repeat: no-repeat;