開發者們大家好!我很高興分享我的最新項目:美食漢堡網站。該項目非常適合那些希望建立一個具有視覺吸引力和功能性的網站來展示各種漢堡選項的人。這是使用 HTML、CSS 和 JavaScript 來增強前端開發技能的好方法,同時為使用者創造令人愉悅的 Web 體驗。
美食漢堡網站是一個網絡應用程序,旨在展示不同的漢堡菜單和特別優惠。它採用簡潔、現代的設計,讓用戶可以輕鬆瀏覽各個部分,例如熱門精選、皇堡、絕妙菜單、新美食精選和每日特惠。該專案演示瞭如何創建一個互動式且美觀的網站。
以下是項目結構的概述:
Foodie-Hamburger/ ├── index.html ├── style.css └── script.js
要開始該項目,請按照以下步驟操作:
複製儲存庫:
git clone https://github.com/abhishekgurjar-in/Foodie-Hamburger.git
開啟專案目錄:
cd Foodie-Hamburger
運行項目:
index.html 檔案定義了美食漢堡網站的結構,包括導航、不同漢堡選項的部分以及頁腳。這是一個片段:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Foodie Hamburger</title> <link href="https://fonts.googleapis.com/css?family=Poppins:100,100italic,200,200italic,300,300italic,regular,italic,500,500italic,600,600italic,700,700italic,800,800italic,900,900italic" rel="stylesheet"> <link rel="stylesheet" href="style.css"> <script src="./script.js" defer></script> </head> <body> <div class="main-content"> <header> <div class="header-content"> <div class="建立一個美食漢堡網站"> <img src="./images/建立一個美食漢堡網站.svg" alt="建立一個美食漢堡網站"> </div> <div class="hamburger-menu-container"> <div class="hamburger-menu"> <span class="hamburger-icon">☰</span> </div> </div> <nav> <span class="close-icon">×</span> <a href="#top-picks">Top Picks</a> <a href="#whooper">Whopper</a> <a href="#stunner-menu">Stunner Menu</a> <a href="#new-foodie-collection">New Foodie Collection</a> <a href="#deal-of-the-day">Deal of the Day</a> </nav> </div> </header> <main> <section class="hero-section"> <div class="img-container"> <img src="./images/hero-image.png" alt="hero-image"> </div> <p>Well, You can’t resist anymore!</p> </section> <section id="top-picks" class="section"> <h2>Top Picks</h2> <div class="img-container"> <img src="./images/burger-1.png" alt="burger-1"> </div> </section> <section id="whooper" class="section"> <h2>Whopper</h2> <div class="img-container"> <img src="./images/burger-2.png" alt="burger-2"> </div> </section> <section id="stunner-menu" class="section"> <h2>Stunner Menu</h2> <div class="img-container"> <img src="./images/burger-3.png" alt="burger-3"> </div> </section> <section id="new-foodie-collection" class="section"> <h2>New Foodie Collection</h2> <div class="img-container"> <img src="./images/burger-4.png" alt="burger-4"> </div> </section> <section id="deal-of-the-day" class="section"> <h2>Deal of the Day</h2> <div class="img-container"> <img src="./images/burger-5.png" alt="burger-5"> </div> </section> <footer> <h3 class="go-to-top"><a href="#">Go to Top</a></h3> <p class="footer-text">Made with ❤️ by Abhishek Gurjar</p> </footer> </main> </div> </body> </html>
style.css 檔案為美食家漢堡網站設計樣式,確保其具有視覺吸引力和響應能力。以下是一些關鍵樣式:
* { box-sizing: border-box; } body { margin: 0; background-color: #f6f0eb; font-family: 'Poppins', sans-serif; } .main-content { overflow-x: hidden; height: 100vh; scroll-behavior: smooth; } a { text-decoration-line: none; color: inherit; } header { background-color: #fff; padding: 24px; } .header-content { max-width: 1290px; display: flex; align-items: center; justify-content: space-between; margin: 0 auto; } nav { display: flex; /* gap: 60px; */ } nav a { font-weight: 700; font-size: 20px; color: #492118; } nav a + a { margin-left: 60px; } .建立一個美食漢堡網站 { width: 50px; } img { width: 100%; } main { padding: 0 24px; } .hero-section { margin-top: 100px; } .img-container { max-width: 1290px; margin: 0 auto; } .hero-section p { color: #492118; text-align: center; font-size: 24px; } .section { margin-top: 120px; } .section .img-container { max-width: 960px; } .section h2 { font-weight: 700; font-size: 48px; color: #492118; text-align: center; } .go-to-top { text-align: right; max-width: 960px; margin: 0 auto; font-size: 32px; margin-top: 80px; } .go-to-top a { text-decoration-line: underline; } .footer-text { text-align: center; color: #858585; font-size: 24px; margin-top: 64px; } .close-icon { position: absolute; top: 8px; right: 12px; cursor: pointer; display: none; } .hamburger-menu-container { overflow: hidden; position: relative; width: 40px; height: 40px; display: none; } .hamburger-menu { width: 100px; height: 100px; border-radius: 50%; position: absolute; top: -64px; right: -58px; background-color: white; cursor: pointer; } .hamburger-icon { font-size: 16px; position: absolute; bottom: 10px; left: 20px; } @media (max-width: 1200px) { nav a { font-size: 16px; } nav a + a { margin-left: 48px; } header { padding: 16px 24px; } } @media (max-width: 960px) { nav a { font-size: 12px; } nav a + a { margin-left: 32px; } .hero-section { margin-top: 32px; } .section { margin-top: 42px; } .hero-section p { font-size: 10px; } .section h2 { font-size: 14px; } } @media (max-width: 768px) { header { background-color: #f6f0ebb7; backdrop-filter: blur(8px); position: sticky; top: 0; padding: 8px 24px; } .header-content { min-height: 40px; } nav { position: absolute; background: rgba(255, 255, 255, 0.9); flex-direction: column; padding: 24px; right: -200px; top: 16px; transition: right 0.25s ease-in-out; /* display: none; */ } nav a + a { margin: 0; margin-top: 16px; } .close-icon, .hamburger-menu-container { display: block; } .menu-open nav { /* display: flex; */ right: 24px; } .menu-open .hamburger-menu-container { display: none; } .go-to-top { font-size: 12px; margin-top: 40px; } .footer-text { font-size: 10px; margin-top: 32px; } .建立一個美食漢堡網站 { width: 30px; } }
script.js 檔案包含根據使用者輸入標籤切換彈出式功能表列的邏輯。這是一個片段:
const hamburgerIcon = document.querySelector('.hamburger-menu-container'); const headerContent = document.querySelector('.header-content'); const closeIcon = document.querySelector('.close-icon'); const nav = document.querySelector('nav'); hamburgerIcon.addEventListener('click', (e) => { e.stopPropagation(); headerContent.classList.add('menu-open'); }); nav.addEventListener('click', (e) => { e.stopPropagation(); }); closeIcon.addEventListener('click', () => { headerContent.classList.remove('menu-open'); }); window.addEventListener('click', () => { headerContent.classList.remove('menu-open'); });
您可以在此處查看美食漢堡網站專案的現場演示。
建立美食家漢堡網站是創造視覺吸引力和互動式網路體驗的絕佳機會。該項目展示了各種漢堡選項和特價優惠,為用戶提供愉快的瀏覽體驗。透過應用 HTML、CSS 和 JavaScript,我們創建了一個響應式且用戶友好的網站,突出了基本的前端開發技能。我希望這個專案能激勵您探索創意的方法來建立引人入勝的網路體驗。快樂編碼!
這個專案是我在 Web 開發方面持續學習之旅的一部分。
以上是建立一個美食漢堡網站的詳細內容。更多資訊請關注PHP中文網其他相關文章!