• <code id="ueasy"></code>
  • \n \n
    \n
    \n\n\n\n

    Key Components:
    \nHeader:<\/p>\n\n

    Logo and Title: Incorporates a Font Awesome icon for a professional touch.
    \nSearch Bar: Allows users to search through your projects in real-time.
    \nTheme Toggle: Enables users to switch between dark and light modes.
    \nNavigation Filters: Buttons to filter projects by category.
    \nGallery:<\/p>\n\n

    Gallery Items: Each project is encapsulated within a gallery-item div, containing an image and an overlay with the project title and description.
    \nLightbox Modal:<\/p>\n\n

    Lightbox Structure: Displays an enlarged view of the project image along with detailed information when a gallery item is clicked.
    \nFooter:<\/p>\n\n

    Social Links: Provides links to your social media profiles and websites with corresponding icons.
    \nStyling with CSS
    \nTo achieve a modern and elegant look, we'll utilize CSS Grid for the gallery layout, flexbox for the header and navigation, and CSS variables for easy theming. We'll also implement responsive design to ensure the portfolio looks great on all devices.
    \n<\/p>\n\n

    \/* =====================================================================\n   1. CSS Variables for Theme Management\n   ===================================================================== *\/\n\n\/* Light Theme Colors *\/\n:root {\n  --color-bg-light: #f0f2f5;\n  --color-text-light: #333333;\n  --color-header-bg-light: #ffffff;\n  --color-header-text-light: #333333;\n  --color-overlay-light: rgba(0, 0, 0, 0.7);\n  --color-footer-bg-light: #ffffff;\n  --color-footer-text-light: #333333;\n  --color-button-bg-light: #e0e0e0;\n  --color-button-hover-light: #333333;\n  --color-button-text-light: #333333;\n  --color-button-hover-text-light: #ffffff;\n\n  \/* Font Sizes *\/\n  --font-size-base: 16px;\n  --font-size-large: 2.5rem;\n  --font-size-medium: 1.2rem;\n  --font-size-small: 0.9rem;\n\n  \/* Transition Duration *\/\n  --transition-duration: 0.3s;\n}\n\n\/* Dark Theme Colors *\/\nbody.dark-mode {\n  --color-bg-dark: #121212;\n  --color-text-dark: #e0e0e0;\n  --color-header-bg-dark: #1e1e1e;\n  --color-header-text-dark: #e0e0e0;\n  --color-overlay-dark: rgba(0, 0, 0, 0.85);\n  --color-footer-bg-dark: #1e1e1e;\n  --color-footer-text-dark: #e0e0e0;\n  --color-button-bg-dark: #333333;\n  --color-button-hover-dark: #ffffff;\n  --color-button-text-dark: #ffffff;\n  --color-button-hover-text-dark: #333333;\n}\n\n\/* =====================================================================\n   2. Reset and Base Styles\n   ===================================================================== *\/\n\n* {\n  margin: 0;\n  padding: 0;\n  box-sizing: border-box;\n}\n\nbody {\n  font-family: 'Roboto', sans-serif;\n  background-color: var(--color-bg-light);\n  color: var(--color-text-light);\n  transition: background-color var(--transition-duration), color var(--transition-duration);\n  line-height: 1.6;\n}\n\n\/* Dark Mode Background and Text *\/\nbody.dark-mode {\n  background-color: var(--color-bg-dark);\n  color: var(--color-text-dark);\n}\n\n\/* =====================================================================\n   3. Header Styles\n   ===================================================================== *\/\n\nheader {\n  background-color: var(--color-header-bg-light);\n  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);\n  position: sticky;\n  top: 0;\n  z-index: 1000;\n  transition: background-color var(--transition-duration), box-shadow var(--transition-duration);\n}\n\nbody.dark-mode header {\n  background-color: var(--color-header-bg-dark);\n  box-shadow: 0 2px 8px rgba(255, 255, 255, 0.1);\n}\n\n.header-container {\n  max-width: 1200px;\n  margin: 0 auto;\n  padding: 1.5rem 2rem;\n  display: flex;\n  flex-direction: column;\n  align-items: center;\n}\n\nheader h1 {\n  font-size: var(--font-size-large);\n  display: flex;\n  align-items: center;\n  gap: 0.5rem;\n  color: var(--color-header-text-light);\n  transition: color var(--transition-duration);\n}\n\nbody.dark-mode .header-container h1 {\n  color: var(--color-header-text-dark);\n}\n\n.header-controls {\n  margin-top: 1rem;\n  display: flex;\n  gap: 1rem;\n  align-items: center;\n}\n\n#searchBar {\n  padding: 0.6rem 1.2rem;\n  border: 1px solid #ccc;\n  border-radius: 30px;\n  width: 250px;\n  transition: border-color var(--transition-duration), background-color var(--transition-duration), color var(--transition-duration);\n}\n\n#searchBar:focus {\n  border-color: #555;\n  outline: none;\n}\n\nbody.dark-mode #searchBar {\n  background-color: #2c2c2c;\n  color: #e0e0e0;\n  border: 1px solid #555;\n}\n\nbody.dark-mode #searchBar::placeholder {\n  color: #aaa;\n}\n\n#themeToggle {\n  background: none;\n  border: none;\n  cursor: pointer;\n  font-size: 1.5rem;\n  color: var(--color-button-text-light);\n  transition: color var(--transition-duration);\n}\n\nbody.dark-mode #themeToggle {\n  color: var(--color-button-text-dark);\n}\n\n#themeToggle:hover {\n  color: var(--color-button-hover-text-light);\n}\n\nbody.dark-mode #themeToggle:hover {\n  color: var(--color-button-hover-text-dark);\n}\n\n\/* =====================================================================\n   4. Navigation Styles\n   ===================================================================== *\/\n\nnav ul {\n  list-style: none;\n  display: flex;\n  justify-content: center;\n  gap: 1rem;\n  margin-top: 1rem;\n}\n\nnav .filter-btn {\n  padding: 0.6rem 1.2rem;\n  border: none;\n  background-color: var(--color-button-bg-light);\n  cursor: pointer;\n  transition: background-color var(--transition-duration), color var(--transition-duration), transform var(--transition-duration);\n  border-radius: 30px;\n  display: flex;\n  align-items: center;\n  gap: 0.5rem;\n  font-size: var(--font-size-medium);\n}\n\nnav .filter-btn:hover {\n  background-color: var(--color-button-hover-light);\n  color: var(--color-button-hover-text-light);\n  transform: translateY(-3px);\n}\n\nnav .filter-btn.active {\n  background-color: #333333;\n  color: #ffffff;\n}\n\nbody.dark-mode nav .filter-btn {\n  background-color: var(--color-button-bg-dark);\n  color: var(--color-button-text-dark);\n}\n\nbody.dark-mode nav .filter-btn:hover {\n  background-color: var(--color-button-hover-dark);\n  color: var(--color-button-hover-text-dark);\n}\n\nbody.dark-mode nav .filter-btn.active {\n  background-color: #ffffff;\n  color: #333333;\n}\n\n\/* =====================================================================\n   5. Gallery Styles\n   ===================================================================== *\/\n\n.gallery {\n  display: grid;\n  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));\n  gap: 2rem;\n  padding: 3rem 2rem;\n  max-width: 1400px;\n  margin: 0 auto;\n}\n\n.gallery-item {\n  position: relative;\n  overflow: hidden;\n  border-radius: 20px;\n  cursor: pointer;\n  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.1);\n  transition: transform var(--transition-duration), box-shadow var(--transition-duration);\n}\n\n.gallery-item:hover {\n  transform: translateY(-15px);\n  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.2);\n}\n\n.gallery-item img {\n  width: 100%;\n  height: auto;\n  display: block;\n  transition: transform var(--transition-duration);\n}\n\n.gallery-item:hover img {\n  transform: scale(1.1);\n}\n\n.overlay {\n  position: absolute;\n  bottom: 0;\n  background: var(--color-overlay-light);\n  color: #ffffff;\n  width: 100%;\n  transform: translateY(100%);\n  transition: transform var(--transition-duration), background-color var(--transition-duration);\n  padding: 1.2rem;\n  text-align: center;\n}\n\n.gallery-item:hover .overlay {\n  transform: translateY(0);\n}\n\nbody.dark-mode .overlay {\n  background: var(--color-overlay-dark);\n}\n\n.overlay h3 {\n  margin-bottom: 0.6rem;\n  font-size: var(--font-size-medium);\n  font-weight: 700;\n}\n\n.overlay p {\n  font-size: var(--font-size-small);\n  line-height: 1.4;\n}\n\n\/* =====================================================================\n   6. Lightbox Styles\n   ===================================================================== *\/\n\n.lightbox {\n  position: fixed;\n  top: 0;\n  left: 0;\n  width: 100%;\n  height: 100%;\n  background-color: rgba(0, 0, 0, 0.95);\n  display: none;\n  justify-content: center;\n  align-items: center;\n  z-index: 2000;\n  animation: fadeIn 0.3s ease;\n}\n\n.lightbox.active {\n  display: flex;\n}\n\n.lightbox-content {\n  position: relative;\n  max-width: 80%;\n  max-height: 80%;\n  background-color: #ffffff;\n  border-radius: 15px;\n  overflow: hidden;\n  animation: slideDown 0.3s ease;\n  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);\n}\n\nbody.dark-mode .lightbox-content {\n  background-color: #1e1e1e;\n  color: #e0e0e0;\n}\n\n.lightbox img {\n  width: 100%;\n  height: auto;\n  display: block;\n}\n\n.lightbox-caption {\n  padding: 1.5rem;\n  background-color: #f9f9f9;\n  transition: background-color var(--transition-duration), color var(--transition-duration);\n}\n\nbody.dark-mode .lightbox-caption {\n  background-color: #2c2c2c;\n}\n\n.lightbox-caption h3 {\n  margin-bottom: 0.8rem;\n  font-size: var(--font-size-medium);\n}\n\n.lightbox-caption p {\n  font-size: var(--font-size-small);\n  line-height: 1.5;\n}\n\n\/* Close Button Styles *\/\n.close {\n  position: absolute;\n  top: 20px;\n  right: 25px;\n  color: #ffffff;\n  font-size: 2rem;\n  cursor: pointer;\n  transition: color var(--transition-duration), transform var(--transition-duration);\n}\n\n.close:hover {\n  color: #cccccc;\n  transform: scale(1.1);\n}\n\nbody.dark-mode .close {\n  color: #e0e0e0;\n}\n\nbody.dark-mode .close:hover {\n  color: #ffffff;\n}\n\n\/* =====================================================================\n   7. Footer Styles\n   ===================================================================== *\/\n\nfooter {\n  text-align: center;\n  padding: 2rem 1rem;\n  background-color: var(--color-footer-bg-light);\n  box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.1);\n  margin-top: 3rem;\n  transition: background-color var(--transition-duration), box-shadow var(--transition-duration);\n}\n\nbody.dark-mode footer {\n  background-color: var(--color-footer-bg-dark);\n  box-shadow: 0 -2px 8px rgba(255, 255, 255, 0.1);\n}\n\nfooter p {\n  font-size: var(--font-size-small);\n  color: var(--color-footer-text-light);\n  transition: color var(--transition-duration);\n}\n\nbody.dark-mode footer p {\n  color: var(--color-footer-text-dark);\n}\n\nfooter a {\n  color: inherit;\n  text-decoration: none;\n  margin: 0 0.5rem;\n  transition: color var(--transition-duration), transform var(--transition-duration);\n}\n\nfooter a:hover {\n  color: #0073e6;\n  transform: scale(1.05);\n}\n\nbody.dark-mode footer a:hover {\n  color: #1e90ff;\n}\n\n\/* =====================================================================\n   8. Responsive Design Adjustments\n   ===================================================================== *\/\n\n@media (max-width: 768px) {\n  header h1 {\n    font-size: 2rem;\n  }\n\n  .header-controls {\n    flex-direction: column;\n    gap: 0.5rem;\n  }\n\n  #searchBar {\n    width: 200px;\n  }\n\n  nav ul {\n    flex-direction: column;\n    gap: 0.5rem;\n  }\n\n  .gallery {\n    padding: 2rem 1rem;\n    gap: 1.5rem;\n  }\n\n  .lightbox-content {\n    max-width: 90%;\n    max-height: 90%;\n  }\n}\n\n@media (max-width: 480px) {\n  header h1 {\n    font-size: 1.8rem;\n  }\n\n  #searchBar {\n    width: 180px;\n  }\n\n  .gallery-item {\n    border-radius: 10px;\n  }\n\n  .overlay h3 {\n    font-size: 1rem;\n  }\n\n  .overlay p {\n    font-size: 0.8rem;\n  }\n\n  .lightbox-caption {\n    padding: 1rem;\n  }\n\n  .lightbox-caption h3 {\n    font-size: 1rem;\n  }\n\n  .lightbox-caption p {\n    font-size: 0.8rem;\n  }\n\n  footer p {\n    font-size: 0.8rem;\n  }\n}\n\n\/* =====================================================================\n   9. Keyframe Animations\n   ===================================================================== *\/\n\n@keyframes fadeIn {\n  from { opacity: 0; }\n  to { opacity: 1; }\n}\n\n@keyframes slideDown {\n  from { transform: translateY(-30px); opacity: 0; }\n  to { transform: translateY(0); opacity: 1; }\n}\n<\/pre>\n\n\n\n

    增強功能說明:
    \n用於主題管理的 CSS 變數(shù):<\/p>\n\n

    淺色和深色主題變數(shù):利用 CSS 變數(shù)可以在整個樣式表中輕鬆主題化和一致的顏色管理。
    \n現(xiàn)代版式與版面:<\/p>\n\n

    字體大小和行高:各種字體大小的定義變數(shù)確保一致性和可擴展性。
    \n盒子陰影和過渡:增加深度和流暢的互動增強視覺吸引力。
    \n響應(yīng)式設(shè)計:<\/p>\n\n

    媒體查詢:確保產(chǎn)品組合無縫適應(yīng)不同的螢?zāi)怀叽纾谛袆友b置、平板電腦和桌上型電腦上提供最佳的觀賞體驗。
    \n互動元素:<\/p>\n\n

    懸停效果:微妙的縮放和陰影增強使互動感覺更加動態(tài)和引人入勝。
    \n平滑過渡:確保主題切換和燈箱動畫等變化感覺自然流暢。
    \n輔助功能注意事項:<\/p>\n\n

    顏色對比:在文字和背景之間保持足夠的對比度,以提高可讀性。
    \n互動式元素大?。喊粹o和互動式元素的大小適當(dāng),以便在所有裝置上輕鬆互動。
    \n使用 JavaScript 新增互動
    \nJavaScript 透過處理使用者互動(例如過濾專案、打開燈箱以及在深色和淺色模式之間切換)來讓您的作品集栩栩如生。
    \n<\/p>\n\n

    \/\/ =====================================================================\n\/\/ 1. Selecting Elements\n\/\/ =====================================================================\n\nconst filterButtons = document.querySelectorAll('.filter-btn');\nconst galleryItems = document.querySelectorAll('.gallery-item');\nconst searchBar = document.getElementById('searchBar');\n\nconst lightbox = document.getElementById('lightbox');\nconst lightboxImg = document.getElementById('lightbox-img');\nconst lightboxTitle = document.getElementById('lightbox-title');\nconst lightboxDescription = document.getElementById('lightbox-description');\nconst closeBtn = document.querySelector('.close');\n\nconst themeToggleBtn = document.getElementById('themeToggle');\nconst body = document.body;\nconst header = document.querySelector('header');\nconst galleryItemsArray = Array.from(galleryItems);\nconst lightboxContent = document.querySelector('.lightbox-content');\nconst overlayElements = document.querySelectorAll('.overlay');\nconst filterBtns = document.querySelectorAll('.filter-btn');\n\n\/\/ =====================================================================\n\/\/ 2. Filtering Functionality\n\/\/ =====================================================================\n\nfunction filterGallery() {\n  const activeFilter = document.querySelector('.filter-btn.active').getAttribute('data-filter');\n  const searchQuery = searchBar.value.toLowerCase();\n\n  galleryItems.forEach(item => {\n    const itemCategory = item.getAttribute('data-category');\n    const itemTitle = item.querySelector('.overlay h3').textContent.toLowerCase();\n\n    if (\n      (activeFilter === 'all' || itemCategory === activeFilter) &&\n      itemTitle.includes(searchQuery)\n    ) {\n      item.style.display = 'block';\n    } else {\n      item.style.display = 'none';\n    }\n  });\n}\n\n\/\/ Event Listeners for Filter Buttons\nfilterButtons.forEach(button => {\n  button.addEventListener('click', () => {\n    \/\/ Remove 'active' class from all buttons\n    filterButtons.forEach(btn => btn.classList.remove('active'));\n    \/\/ Add 'active' class to the clicked button\n    button.classList.add('active');\n\n    \/\/ Filter the gallery based on the selected category\n    filterGallery();\n  });\n});\n\n\/\/ Event Listener for Search Bar\nsearchBar.addEventListener('input', () => {\n  filterGallery();\n});\n\n\/\/ =====================================================================\n\/\/ 3. Lightbox Functionality\n\/\/ =====================================================================\n\n\/\/ Function to Open Lightbox\nfunction openLightbox(item) {\n  const imgSrc = item.querySelector('img').src;\n  const title = item.querySelector('.overlay h3').textContent;\n  const description = item.querySelector('.overlay p').textContent;\n\n  lightboxImg.src = imgSrc;\n  lightboxTitle.textContent = title;\n  lightboxDescription.textContent = description;\n\n  lightbox.classList.add('active');\n  body.style.overflow = 'hidden'; \/\/ Prevent background scrolling\n}\n\n\/\/ Event Listeners for Gallery Items\ngalleryItems.forEach(item => {\n  item.addEventListener('click', () => {\n    openLightbox(item);\n  });\n});\n\n\/\/ Function to Close Lightbox\nfunction closeLightbox() {\n  lightbox.classList.remove('active');\n  body.style.overflow = 'auto'; \/\/ Restore background scrolling\n}\n\n\/\/ Event Listener for Close Button\ncloseBtn.addEventListener('click', () => {\n  closeLightbox();\n});\n\n\/\/ Event Listener for Clicking Outside Lightbox Content\nwindow.addEventListener('click', (e) => {\n  if (e.target === lightbox) {\n    closeLightbox();\n  }\n});\n\n\/\/ =====================================================================\n\/\/ 4. Theme Toggle Functionality\n\/\/ =====================================================================\n\n\/\/ Retrieve Saved Theme from Local Storage\nconst savedTheme = localStorage.getItem('theme') || 'light-mode';\n\n\/\/ Function to Apply Theme\nfunction applyTheme(theme) {\n  if (theme === 'dark-mode') {\n    body.classList.add('dark-mode');\n    header.classList.add('dark-mode');\n    lightbox.classList.add('dark-mode');\n    lightboxContent.classList.add('dark-mode');\n    overlayElements.forEach(el => el.classList.add('dark-mode'));\n    galleryItemsArray.forEach(item => item.classList.add('dark-mode'));\n    filterBtns.forEach(btn => btn.classList.add('dark-mode'));\n\n    \/\/ Change Icon to Sun\n    themeToggleBtn.querySelector('i').classList.remove('fa-moon');\n    themeToggleBtn.querySelector('i').classList.add('fa-sun');\n  } else {\n    body.classList.remove('dark-mode');\n    header.classList.remove('dark-mode');\n    lightbox.classList.remove('dark-mode');\n    lightboxContent.classList.remove('dark-mode');\n    overlayElements.forEach(el => el.classList.remove('dark-mode'));\n    galleryItemsArray.forEach(item => item.classList.remove('dark-mode'));\n    filterBtns.forEach(btn => btn.classList.remove('dark-mode'));\n\n    \/\/ Change Icon to Moon\n    themeToggleBtn.querySelector('i').classList.remove('fa-sun');\n    themeToggleBtn.querySelector('i').classList.add('fa-moon');\n  }\n}\n\n\/\/ Apply Saved Theme on Page Load\napplyTheme(savedTheme);\n\n\/\/ Event Listener for Theme Toggle Button\nthemeToggleBtn.addEventListener('click', () => {\n  if (body.classList.contains('dark-mode')) {\n    applyTheme('light-mode');\n    localStorage.setItem('theme', 'light-mode');\n  } else {\n    applyTheme('dark-mode');\n    localStorage.setItem('theme', 'dark-mode');\n  }\n});\n<\/pre>\n\n\n\n

    主要功能:
    \n篩選項目:<\/p>\n\n

    基於類別的過濾:使用者可以按網(wǎng)頁設(shè)計、平面設(shè)計和攝影等類別過濾項目。
    \n即時搜尋:搜尋列根據(jù)輸入過濾項目,增強使用者體驗。
    \n燈箱模態(tài):<\/p>\n\n

    圖像放大:點擊項目將開啟一個模式,顯示更大的圖像和詳細說明。
    \n無縫導(dǎo)航:使用者可以透過點擊關(guān)閉按鈕或內(nèi)容區(qū)域之外輕鬆關(guān)閉模式。
    \n暗\/亮模式切換:<\/p>\n

    使用者偏好:使用者可以在深色和淺色主題之間切換,並將他們的偏好保存在 localStorage 中以便跨會話持久保存。
    \n圖示切換:切換按鈕圖示動態(tài)變化以反映目前主題。
    \n實施暗\/亮模式
    \n深色模式不僅提供了現(xiàn)代美感,還增強了使用者在低光源環(huán)境下的可訪問性。以下是如何在您的作品集中整合暗\/亮模式切換:<\/p>\n\n

    CSS 變數(shù):我們已經(jīng)為淺色和深色主題定義了變數(shù)。
    \nJavaScript Toggle:script.js 處理暗模式類別的新增和刪除,從而相應(yīng)地更改主題。
    \n保留使用者偏好:使用 localStorage,儲存使用者的主題偏好並在後續(xù)造訪時套用。
    \n增強使用者體驗:搜尋與過濾
    \n動態(tài)過濾和即時搜尋欄使用戶能夠輕鬆瀏覽您的專案。 <\/p>\n\n

    按類別過濾:使用者可以點擊篩選按鈕來查看特定類別內(nèi)的項目。
    \n即時搜尋:當(dāng)使用者在搜尋欄中輸入內(nèi)容時,系統(tǒng)會根據(jù)輸入即時篩選項目,提供即時回饋。
    \n優(yōu)化回應(yīng)能力和可訪問性
    \n優(yōu)雅的產(chǎn)品組合必須響應(yīng)迅速且易於訪問,以滿足所有用戶的需求。 <\/p>\n\n

    響應(yīng)式設(shè)計:<\/p>\n\n

    靈活的佈局:使用 CSS Grid 和 Flexbox 確保圖庫適應(yīng)各種螢?zāi)怀叽纭?
    \n媒體查詢:根據(jù)裝置寬度調(diào)整字體大小、填充和佈局,以獲得最佳觀看效果。
    \n輔助功能:<\/p>\n\n

    圖像的替代文字:描述性替代屬性可提高螢?zāi)婚喿x器的可存取性。
    \n鍵盤導(dǎo)航:確保所有互動元素都可以透過鍵盤存取。
    \n顏色對比:保持文字和背景之間的高對比度以提高可讀性。
    \n部署您的投資組合
    \n一旦對您的產(chǎn)品組合感到滿意,就可以部署給全世界看。 <\/p>\n\n

    託管平臺:<\/p>\n\n

    GitHub Pages:靜態(tài)網(wǎng)站的免費主機服務(wù)。
    \nNetlify:提供持續(xù)部署和免費託管以及自訂網(wǎng)域支援。
    \nVercel:為前端專案提供無縫部署。
    \n自訂域:<\/p>\n\n

    購買自訂域名,讓您的作品集更加專業(yè)和難忘。
    \nSEO 優(yōu)化:<\/p>\n\n

    使用有意義的元標(biāo)籤、標(biāo)題和描述。
    \n透過壓縮圖片和縮小 CSS\/JS 檔案來優(yōu)化載入時間。
    \n推廣您的投資組合
    \n擁有令人驚嘆的投資組合只是第一步。推廣它可以確保它到達您的目標(biāo)受眾。 <\/p>\n\n

    社群媒體:<\/p>\n\n

    在 LinkedIn、Twitter 和 Facebook 等平臺上分享您的作品集。
    \n使用相關(guān)主題標(biāo)籤來提高可見度。
    \n網(wǎng)路:<\/p>\n\n

    與 Reddit、Stack Overflow 或 Dribbble 上的社群互動。
    \n參加虛擬或面對面的社交活動來展示您的作品。
    \n搜尋引擎優(yōu)化與內(nèi)容行銷:<\/p>\n

    建立與您的領(lǐng)域相關(guān)的部落格以增加自然流量。
    \n使用相關(guān)關(guān)鍵字針對搜尋引擎優(yōu)化您的作品集。
    \n電子郵件簽名:<\/p>\n\n

    在電子郵件簽名中包含指向您的作品集的鏈接,以被動地推廣它。
    \n結(jié)論
    \n創(chuàng)建優(yōu)雅的互動式作品集畫廊是一項有益的努力,它以專業(yè)且引人入勝的方式展示您的技能和專案。透過利用 HTML5、CSS3 和 JavaScript,您可以建立在數(shù)位領(lǐng)域脫穎而出的響應(yīng)式動態(tài)產(chǎn)品組合。 <\/p>\n\n

    探索更多我的作品:
    \nLinkedIn:皮耶-羅曼洛佩茲
    \n角鬥士之戰(zhàn):gladiatorsbattle.com
    \nDivWeb:divweb.fr
    \n推特:@GladiatorsBT
    \nJeanFernandsEtti:jeanfernandsetti.fr
    \nXavierFlabat:xavier-flabat.com
    \n請隨時透過我的社交媒體管道或訪問我的網(wǎng)站來了解有關(guān)我的項目和服務(wù)的更多資訊。我始終對合作和新機會持開放態(tài)度! <\/p>\n\n

    祝您編碼愉快,祝您的作品好運! ??<\/p>\n\n

    作者簡介
    \nPierre-Romain Lopez 是一位充滿熱情的 Web 開發(fā)人員和設(shè)計師,對細節(jié)有著敏銳的洞察力,致力於創(chuàng)造引人入勝且使用者友好的數(shù)位體驗。 Pierre-Romain 擁有涵蓋網(wǎng)頁設(shè)計、平面設(shè)計和攝影的多元化產(chǎn)品組合,擅長透過程式碼和設(shè)計將創(chuàng)意願景變?yōu)??現(xiàn)實。 <\/p>\n\n\n \n\n \n "}

    国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

    首頁 web前端 js教程 使用 HTMLCSS 和 JavaScript 建立優(yōu)雅的互動式作品集畫廊

    使用 HTMLCSS 和 JavaScript 建立優(yōu)雅的互動式作品集畫廊

    Nov 17, 2024 pm 09:25 PM

    Building an Elegant Interactive Portfolio Gallery with HTMLCSSand JavaScript

    在當(dāng)今的數(shù)位時代,您的作品集可以作為您的專業(yè)名片。無論您是網(wǎng)頁開發(fā)人員、平面設(shè)計師、攝影師或任何創(chuàng)意專業(yè)人士,精美的互動式作品集都可以顯著增強您的線上形象、展示您的技能並吸引潛在客戶或雇主。在本教程中,我們將引導(dǎo)您使用 HTML5、CSS3 和 JavaScript 建立複雜的互動式作品集。最後,您將擁有一個響應(yīng)式圖庫,具有動態(tài)過濾、即時搜尋列、暗/亮模式切換以及直覺的燈箱模式,可有效顯示您的項目。

    圖1:優(yōu)雅的互動作品集預(yù)覽

    目錄

    1. 為什麼是互動作品集?
    2. 先決條件
    3. 設(shè)定項目結(jié)構(gòu)
    4. 建立 HTML 結(jié)構(gòu)
    5. 使用 CSS 樣式
    6. 使用 JavaScript 加入互動性
    7. 實現(xiàn)暗/亮模式
    8. 增強使用者體驗:搜尋與過濾
    9. 最佳化回應(yīng)能力和可訪問性
    10. 部署您的投資組合
    11. 推廣您的作品集
    12. 結(jié)論
    13. 為什麼是互動作品集?
    14. 互動式作品集不僅僅是列出您的專案;它吸引訪客,突出您的技能,並展示您創(chuàng)建用戶友好且美觀的介面的能力。過濾、搜尋列和暗/亮模式等互動元素不僅可以增強使用者體驗,還可以展示您對現(xiàn)代 Web 開發(fā)技術(shù)的熟練程度。

    先決條件
    在深入建立您的投資組合之前,請確保您擁有:

    HTML、CSS 和 JavaScript 的基礎(chǔ)知識:了解基礎(chǔ)知識至關(guān)重要。
    程式碼編輯器:建議使用 Visual Studio Code、Sublime Text 或 Atom 等工具。
    網(wǎng)頁瀏覽器:帶有開發(fā)人員工具的現(xiàn)代瀏覽器,例如 Google Chrome 或 Mozilla Firefox。
    您的專案圖像:展示您作品的高品質(zhì)視覺效果。
    設(shè)定項目結(jié)構(gòu)
    有系統(tǒng)地組織您的專案文件,以便於管理和可擴展性。

    作品集畫廊/

    ├──index.html
    ├── styles.css
    ├── script.js
    └── 資產(chǎn)/
    └── 圖片/
    ├── web-project1.jpg
    ├── 圖形項目1.jpg
    └── 攝影-project1.jpg
    index.html:主要 HTML 檔案。
    styles.css:包含所有 CSS 樣式。
    script.js:保存用於互動的 JavaScript 程式碼。
    asset/images/: 項目圖片目錄。
    建立 HTML 結(jié)構(gòu)
    首先製作語義且可存取的 HTML 結(jié)構(gòu)。這個基礎(chǔ)可確保您的作品集用戶友好且經(jīng)過 SEO 優(yōu)化。

    <!DOCTYPE html>
    <html lang="en">
    <head>
      <meta charset="UTF-8">
      <meta name="viewport" content="width=device-width, initial-scale=1">
      <title>Elegant Interactive Portfolio Gallery</title>
      <!-- Font Awesome for Icons -->
      <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
      <!-- Google Fonts for Typography -->
      <link href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;700&display=swap" rel="stylesheet">
      <!-- Stylesheet -->
      <link rel="stylesheet" href="styles.css">
    </head>
    <body>
      <!-- Header Section -->
      <header>
        <div>
    
    
    
    <p>Key Components:<br>
    Header:</p>
    
    <p>Logo and Title: Incorporates a Font Awesome icon for a professional touch.<br>
    Search Bar: Allows users to search through your projects in real-time.<br>
    Theme Toggle: Enables users to switch between dark and light modes.<br>
    Navigation Filters: Buttons to filter projects by category.<br>
    Gallery:</p>
    
    <p>Gallery Items: Each project is encapsulated within a gallery-item div, containing an image and an overlay with the project title and description.<br>
    Lightbox Modal:</p>
    
    <p>Lightbox Structure: Displays an enlarged view of the project image along with detailed information when a gallery item is clicked.<br>
    Footer:</p>
    
    <p>Social Links: Provides links to your social media profiles and websites with corresponding icons.<br>
    Styling with CSS<br>
    To achieve a modern and elegant look, we'll utilize CSS Grid for the gallery layout, flexbox for the header and navigation, and CSS variables for easy theming. We'll also implement responsive design to ensure the portfolio looks great on all devices.<br>
    </p>
    
    <pre class="brush:php;toolbar:false">/* =====================================================================
       1. CSS Variables for Theme Management
       ===================================================================== */
    
    /* Light Theme Colors */
    :root {
      --color-bg-light: #f0f2f5;
      --color-text-light: #333333;
      --color-header-bg-light: #ffffff;
      --color-header-text-light: #333333;
      --color-overlay-light: rgba(0, 0, 0, 0.7);
      --color-footer-bg-light: #ffffff;
      --color-footer-text-light: #333333;
      --color-button-bg-light: #e0e0e0;
      --color-button-hover-light: #333333;
      --color-button-text-light: #333333;
      --color-button-hover-text-light: #ffffff;
    
      /* Font Sizes */
      --font-size-base: 16px;
      --font-size-large: 2.5rem;
      --font-size-medium: 1.2rem;
      --font-size-small: 0.9rem;
    
      /* Transition Duration */
      --transition-duration: 0.3s;
    }
    
    /* Dark Theme Colors */
    body.dark-mode {
      --color-bg-dark: #121212;
      --color-text-dark: #e0e0e0;
      --color-header-bg-dark: #1e1e1e;
      --color-header-text-dark: #e0e0e0;
      --color-overlay-dark: rgba(0, 0, 0, 0.85);
      --color-footer-bg-dark: #1e1e1e;
      --color-footer-text-dark: #e0e0e0;
      --color-button-bg-dark: #333333;
      --color-button-hover-dark: #ffffff;
      --color-button-text-dark: #ffffff;
      --color-button-hover-text-dark: #333333;
    }
    
    /* =====================================================================
       2. Reset and Base Styles
       ===================================================================== */
    
    * {
      margin: 0;
      padding: 0;
      box-sizing: border-box;
    }
    
    body {
      font-family: 'Roboto', sans-serif;
      background-color: var(--color-bg-light);
      color: var(--color-text-light);
      transition: background-color var(--transition-duration), color var(--transition-duration);
      line-height: 1.6;
    }
    
    /* Dark Mode Background and Text */
    body.dark-mode {
      background-color: var(--color-bg-dark);
      color: var(--color-text-dark);
    }
    
    /* =====================================================================
       3. Header Styles
       ===================================================================== */
    
    header {
      background-color: var(--color-header-bg-light);
      box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
      position: sticky;
      top: 0;
      z-index: 1000;
      transition: background-color var(--transition-duration), box-shadow var(--transition-duration);
    }
    
    body.dark-mode header {
      background-color: var(--color-header-bg-dark);
      box-shadow: 0 2px 8px rgba(255, 255, 255, 0.1);
    }
    
    .header-container {
      max-width: 1200px;
      margin: 0 auto;
      padding: 1.5rem 2rem;
      display: flex;
      flex-direction: column;
      align-items: center;
    }
    
    header h1 {
      font-size: var(--font-size-large);
      display: flex;
      align-items: center;
      gap: 0.5rem;
      color: var(--color-header-text-light);
      transition: color var(--transition-duration);
    }
    
    body.dark-mode .header-container h1 {
      color: var(--color-header-text-dark);
    }
    
    .header-controls {
      margin-top: 1rem;
      display: flex;
      gap: 1rem;
      align-items: center;
    }
    
    #searchBar {
      padding: 0.6rem 1.2rem;
      border: 1px solid #ccc;
      border-radius: 30px;
      width: 250px;
      transition: border-color var(--transition-duration), background-color var(--transition-duration), color var(--transition-duration);
    }
    
    #searchBar:focus {
      border-color: #555;
      outline: none;
    }
    
    body.dark-mode #searchBar {
      background-color: #2c2c2c;
      color: #e0e0e0;
      border: 1px solid #555;
    }
    
    body.dark-mode #searchBar::placeholder {
      color: #aaa;
    }
    
    #themeToggle {
      background: none;
      border: none;
      cursor: pointer;
      font-size: 1.5rem;
      color: var(--color-button-text-light);
      transition: color var(--transition-duration);
    }
    
    body.dark-mode #themeToggle {
      color: var(--color-button-text-dark);
    }
    
    #themeToggle:hover {
      color: var(--color-button-hover-text-light);
    }
    
    body.dark-mode #themeToggle:hover {
      color: var(--color-button-hover-text-dark);
    }
    
    /* =====================================================================
       4. Navigation Styles
       ===================================================================== */
    
    nav ul {
      list-style: none;
      display: flex;
      justify-content: center;
      gap: 1rem;
      margin-top: 1rem;
    }
    
    nav .filter-btn {
      padding: 0.6rem 1.2rem;
      border: none;
      background-color: var(--color-button-bg-light);
      cursor: pointer;
      transition: background-color var(--transition-duration), color var(--transition-duration), transform var(--transition-duration);
      border-radius: 30px;
      display: flex;
      align-items: center;
      gap: 0.5rem;
      font-size: var(--font-size-medium);
    }
    
    nav .filter-btn:hover {
      background-color: var(--color-button-hover-light);
      color: var(--color-button-hover-text-light);
      transform: translateY(-3px);
    }
    
    nav .filter-btn.active {
      background-color: #333333;
      color: #ffffff;
    }
    
    body.dark-mode nav .filter-btn {
      background-color: var(--color-button-bg-dark);
      color: var(--color-button-text-dark);
    }
    
    body.dark-mode nav .filter-btn:hover {
      background-color: var(--color-button-hover-dark);
      color: var(--color-button-hover-text-dark);
    }
    
    body.dark-mode nav .filter-btn.active {
      background-color: #ffffff;
      color: #333333;
    }
    
    /* =====================================================================
       5. Gallery Styles
       ===================================================================== */
    
    .gallery {
      display: grid;
      grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
      gap: 2rem;
      padding: 3rem 2rem;
      max-width: 1400px;
      margin: 0 auto;
    }
    
    .gallery-item {
      position: relative;
      overflow: hidden;
      border-radius: 20px;
      cursor: pointer;
      box-shadow: 0 6px 18px rgba(0, 0, 0, 0.1);
      transition: transform var(--transition-duration), box-shadow var(--transition-duration);
    }
    
    .gallery-item:hover {
      transform: translateY(-15px);
      box-shadow: 0 12px 24px rgba(0, 0, 0, 0.2);
    }
    
    .gallery-item img {
      width: 100%;
      height: auto;
      display: block;
      transition: transform var(--transition-duration);
    }
    
    .gallery-item:hover img {
      transform: scale(1.1);
    }
    
    .overlay {
      position: absolute;
      bottom: 0;
      background: var(--color-overlay-light);
      color: #ffffff;
      width: 100%;
      transform: translateY(100%);
      transition: transform var(--transition-duration), background-color var(--transition-duration);
      padding: 1.2rem;
      text-align: center;
    }
    
    .gallery-item:hover .overlay {
      transform: translateY(0);
    }
    
    body.dark-mode .overlay {
      background: var(--color-overlay-dark);
    }
    
    .overlay h3 {
      margin-bottom: 0.6rem;
      font-size: var(--font-size-medium);
      font-weight: 700;
    }
    
    .overlay p {
      font-size: var(--font-size-small);
      line-height: 1.4;
    }
    
    /* =====================================================================
       6. Lightbox Styles
       ===================================================================== */
    
    .lightbox {
      position: fixed;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      background-color: rgba(0, 0, 0, 0.95);
      display: none;
      justify-content: center;
      align-items: center;
      z-index: 2000;
      animation: fadeIn 0.3s ease;
    }
    
    .lightbox.active {
      display: flex;
    }
    
    .lightbox-content {
      position: relative;
      max-width: 80%;
      max-height: 80%;
      background-color: #ffffff;
      border-radius: 15px;
      overflow: hidden;
      animation: slideDown 0.3s ease;
      box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
    }
    
    body.dark-mode .lightbox-content {
      background-color: #1e1e1e;
      color: #e0e0e0;
    }
    
    .lightbox img {
      width: 100%;
      height: auto;
      display: block;
    }
    
    .lightbox-caption {
      padding: 1.5rem;
      background-color: #f9f9f9;
      transition: background-color var(--transition-duration), color var(--transition-duration);
    }
    
    body.dark-mode .lightbox-caption {
      background-color: #2c2c2c;
    }
    
    .lightbox-caption h3 {
      margin-bottom: 0.8rem;
      font-size: var(--font-size-medium);
    }
    
    .lightbox-caption p {
      font-size: var(--font-size-small);
      line-height: 1.5;
    }
    
    /* Close Button Styles */
    .close {
      position: absolute;
      top: 20px;
      right: 25px;
      color: #ffffff;
      font-size: 2rem;
      cursor: pointer;
      transition: color var(--transition-duration), transform var(--transition-duration);
    }
    
    .close:hover {
      color: #cccccc;
      transform: scale(1.1);
    }
    
    body.dark-mode .close {
      color: #e0e0e0;
    }
    
    body.dark-mode .close:hover {
      color: #ffffff;
    }
    
    /* =====================================================================
       7. Footer Styles
       ===================================================================== */
    
    footer {
      text-align: center;
      padding: 2rem 1rem;
      background-color: var(--color-footer-bg-light);
      box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.1);
      margin-top: 3rem;
      transition: background-color var(--transition-duration), box-shadow var(--transition-duration);
    }
    
    body.dark-mode footer {
      background-color: var(--color-footer-bg-dark);
      box-shadow: 0 -2px 8px rgba(255, 255, 255, 0.1);
    }
    
    footer p {
      font-size: var(--font-size-small);
      color: var(--color-footer-text-light);
      transition: color var(--transition-duration);
    }
    
    body.dark-mode footer p {
      color: var(--color-footer-text-dark);
    }
    
    footer a {
      color: inherit;
      text-decoration: none;
      margin: 0 0.5rem;
      transition: color var(--transition-duration), transform var(--transition-duration);
    }
    
    footer a:hover {
      color: #0073e6;
      transform: scale(1.05);
    }
    
    body.dark-mode footer a:hover {
      color: #1e90ff;
    }
    
    /* =====================================================================
       8. Responsive Design Adjustments
       ===================================================================== */
    
    @media (max-width: 768px) {
      header h1 {
        font-size: 2rem;
      }
    
      .header-controls {
        flex-direction: column;
        gap: 0.5rem;
      }
    
      #searchBar {
        width: 200px;
      }
    
      nav ul {
        flex-direction: column;
        gap: 0.5rem;
      }
    
      .gallery {
        padding: 2rem 1rem;
        gap: 1.5rem;
      }
    
      .lightbox-content {
        max-width: 90%;
        max-height: 90%;
      }
    }
    
    @media (max-width: 480px) {
      header h1 {
        font-size: 1.8rem;
      }
    
      #searchBar {
        width: 180px;
      }
    
      .gallery-item {
        border-radius: 10px;
      }
    
      .overlay h3 {
        font-size: 1rem;
      }
    
      .overlay p {
        font-size: 0.8rem;
      }
    
      .lightbox-caption {
        padding: 1rem;
      }
    
      .lightbox-caption h3 {
        font-size: 1rem;
      }
    
      .lightbox-caption p {
        font-size: 0.8rem;
      }
    
      footer p {
        font-size: 0.8rem;
      }
    }
    
    /* =====================================================================
       9. Keyframe Animations
       ===================================================================== */
    
    @keyframes fadeIn {
      from { opacity: 0; }
      to { opacity: 1; }
    }
    
    @keyframes slideDown {
      from { transform: translateY(-30px); opacity: 0; }
      to { transform: translateY(0); opacity: 1; }
    }
    

    增強功能說明:
    用於主題管理的 CSS 變數(shù):

    淺色和深色主題變數(shù):利用 CSS 變數(shù)可以在整個樣式表中輕鬆主題化和一致的顏色管理。
    現(xiàn)代版式與版面:

    字體大小和行高:各種字體大小的定義變數(shù)確保一致性和可擴展性。
    盒子陰影和過渡:增加深度和流暢的互動增強視覺吸引力。
    響應(yīng)式設(shè)計:

    媒體查詢:確保產(chǎn)品組合無縫適應(yīng)不同的螢?zāi)怀叽?,在行動裝置、平板電腦和桌上型電腦上提供最佳的觀賞體驗。
    互動元素:

    懸停效果:微妙的縮放和陰影增強使互動感覺更加動態(tài)和引人入勝。
    平滑過渡:確保主題切換和燈箱動畫等變化感覺自然流暢。
    輔助功能注意事項:

    顏色對比:在文字和背景之間保持足夠的對比度,以提高可讀性。
    互動式元素大?。喊粹o和互動式元素的大小適當(dāng),以便在所有裝置上輕鬆互動。
    使用 JavaScript 新增互動
    JavaScript 透過處理使用者互動(例如過濾專案、打開燈箱以及在深色和淺色模式之間切換)來讓您的作品集栩栩如生。

    // =====================================================================
    // 1. Selecting Elements
    // =====================================================================
    
    const filterButtons = document.querySelectorAll('.filter-btn');
    const galleryItems = document.querySelectorAll('.gallery-item');
    const searchBar = document.getElementById('searchBar');
    
    const lightbox = document.getElementById('lightbox');
    const lightboxImg = document.getElementById('lightbox-img');
    const lightboxTitle = document.getElementById('lightbox-title');
    const lightboxDescription = document.getElementById('lightbox-description');
    const closeBtn = document.querySelector('.close');
    
    const themeToggleBtn = document.getElementById('themeToggle');
    const body = document.body;
    const header = document.querySelector('header');
    const galleryItemsArray = Array.from(galleryItems);
    const lightboxContent = document.querySelector('.lightbox-content');
    const overlayElements = document.querySelectorAll('.overlay');
    const filterBtns = document.querySelectorAll('.filter-btn');
    
    // =====================================================================
    // 2. Filtering Functionality
    // =====================================================================
    
    function filterGallery() {
      const activeFilter = document.querySelector('.filter-btn.active').getAttribute('data-filter');
      const searchQuery = searchBar.value.toLowerCase();
    
      galleryItems.forEach(item => {
        const itemCategory = item.getAttribute('data-category');
        const itemTitle = item.querySelector('.overlay h3').textContent.toLowerCase();
    
        if (
          (activeFilter === 'all' || itemCategory === activeFilter) &&
          itemTitle.includes(searchQuery)
        ) {
          item.style.display = 'block';
        } else {
          item.style.display = 'none';
        }
      });
    }
    
    // Event Listeners for Filter Buttons
    filterButtons.forEach(button => {
      button.addEventListener('click', () => {
        // Remove 'active' class from all buttons
        filterButtons.forEach(btn => btn.classList.remove('active'));
        // Add 'active' class to the clicked button
        button.classList.add('active');
    
        // Filter the gallery based on the selected category
        filterGallery();
      });
    });
    
    // Event Listener for Search Bar
    searchBar.addEventListener('input', () => {
      filterGallery();
    });
    
    // =====================================================================
    // 3. Lightbox Functionality
    // =====================================================================
    
    // Function to Open Lightbox
    function openLightbox(item) {
      const imgSrc = item.querySelector('img').src;
      const title = item.querySelector('.overlay h3').textContent;
      const description = item.querySelector('.overlay p').textContent;
    
      lightboxImg.src = imgSrc;
      lightboxTitle.textContent = title;
      lightboxDescription.textContent = description;
    
      lightbox.classList.add('active');
      body.style.overflow = 'hidden'; // Prevent background scrolling
    }
    
    // Event Listeners for Gallery Items
    galleryItems.forEach(item => {
      item.addEventListener('click', () => {
        openLightbox(item);
      });
    });
    
    // Function to Close Lightbox
    function closeLightbox() {
      lightbox.classList.remove('active');
      body.style.overflow = 'auto'; // Restore background scrolling
    }
    
    // Event Listener for Close Button
    closeBtn.addEventListener('click', () => {
      closeLightbox();
    });
    
    // Event Listener for Clicking Outside Lightbox Content
    window.addEventListener('click', (e) => {
      if (e.target === lightbox) {
        closeLightbox();
      }
    });
    
    // =====================================================================
    // 4. Theme Toggle Functionality
    // =====================================================================
    
    // Retrieve Saved Theme from Local Storage
    const savedTheme = localStorage.getItem('theme') || 'light-mode';
    
    // Function to Apply Theme
    function applyTheme(theme) {
      if (theme === 'dark-mode') {
        body.classList.add('dark-mode');
        header.classList.add('dark-mode');
        lightbox.classList.add('dark-mode');
        lightboxContent.classList.add('dark-mode');
        overlayElements.forEach(el => el.classList.add('dark-mode'));
        galleryItemsArray.forEach(item => item.classList.add('dark-mode'));
        filterBtns.forEach(btn => btn.classList.add('dark-mode'));
    
        // Change Icon to Sun
        themeToggleBtn.querySelector('i').classList.remove('fa-moon');
        themeToggleBtn.querySelector('i').classList.add('fa-sun');
      } else {
        body.classList.remove('dark-mode');
        header.classList.remove('dark-mode');
        lightbox.classList.remove('dark-mode');
        lightboxContent.classList.remove('dark-mode');
        overlayElements.forEach(el => el.classList.remove('dark-mode'));
        galleryItemsArray.forEach(item => item.classList.remove('dark-mode'));
        filterBtns.forEach(btn => btn.classList.remove('dark-mode'));
    
        // Change Icon to Moon
        themeToggleBtn.querySelector('i').classList.remove('fa-sun');
        themeToggleBtn.querySelector('i').classList.add('fa-moon');
      }
    }
    
    // Apply Saved Theme on Page Load
    applyTheme(savedTheme);
    
    // Event Listener for Theme Toggle Button
    themeToggleBtn.addEventListener('click', () => {
      if (body.classList.contains('dark-mode')) {
        applyTheme('light-mode');
        localStorage.setItem('theme', 'light-mode');
      } else {
        applyTheme('dark-mode');
        localStorage.setItem('theme', 'dark-mode');
      }
    });
    

    主要功能:
    篩選項目:

    基於類別的過濾:使用者可以按網(wǎng)頁設(shè)計、平面設(shè)計和攝影等類別過濾項目。
    即時搜尋:搜尋列根據(jù)輸入過濾項目,增強使用者體驗。
    燈箱模態(tài):

    圖像放大:點擊項目將開啟一個模式,顯示更大的圖像和詳細說明。
    無縫導(dǎo)航:使用者可以透過點擊關(guān)閉按鈕或內(nèi)容區(qū)域之外輕鬆關(guān)閉模式。
    暗/亮模式切換:

    使用者偏好:使用者可以在深色和淺色主題之間切換,並將他們的偏好保存在 localStorage 中以便跨會話持久保存。
    圖示切換:切換按鈕圖示動態(tài)變化以反映目前主題。
    實施暗/亮模式
    深色模式不僅提供了現(xiàn)代美感,還增強了使用者在低光源環(huán)境下的可訪問性。以下是如何在您的作品集中整合暗/亮模式切換:

    CSS 變數(shù):我們已經(jīng)為淺色和深色主題定義了變數(shù)。
    JavaScript Toggle:script.js 處理暗模式類別的新增和刪除,從而相應(yīng)地更改主題。
    保留使用者偏好:使用 localStorage,儲存使用者的主題偏好並在後續(xù)造訪時套用。
    增強使用者體驗:搜尋與過濾
    動態(tài)過濾和即時搜尋欄使用戶能夠輕鬆瀏覽您的專案。

    按類別過濾:使用者可以點擊篩選按鈕來查看特定類別內(nèi)的項目。
    即時搜尋:當(dāng)使用者在搜尋欄中輸入內(nèi)容時,系統(tǒng)會根據(jù)輸入即時篩選項目,提供即時回饋。
    優(yōu)化回應(yīng)能力和可訪問性
    優(yōu)雅的產(chǎn)品組合必須響應(yīng)迅速且易於訪問,以滿足所有用戶的需求。

    響應(yīng)式設(shè)計:

    靈活的佈局:使用 CSS Grid 和 Flexbox 確保圖庫適應(yīng)各種螢?zāi)怀叽纭?
    媒體查詢:根據(jù)裝置寬度調(diào)整字體大小、填充和佈局,以獲得最佳觀看效果。
    輔助功能:

    圖像的替代文字:描述性替代屬性可提高螢?zāi)婚喿x器的可存取性。
    鍵盤導(dǎo)航:確保所有互動元素都可以透過鍵盤存取。
    顏色對比:保持文字和背景之間的高對比度以提高可讀性。
    部署您的投資組合
    一旦對您的產(chǎn)品組合感到滿意,就可以部署給全世界看。

    託管平臺:

    GitHub Pages:靜態(tài)網(wǎng)站的免費主機服務(wù)。
    Netlify:提供持續(xù)部署和免費託管以及自訂網(wǎng)域支援。
    Vercel:為前端專案提供無縫部署。
    自訂域:

    購買自訂域名,讓您的作品集更加專業(yè)和難忘。
    SEO 優(yōu)化:

    使用有意義的元標(biāo)籤、標(biāo)題和描述。
    透過壓縮圖片和縮小 CSS/JS 檔案來優(yōu)化載入時間。
    推廣您的投資組合
    擁有令人驚嘆的投資組合只是第一步。推廣它可以確保它到達您的目標(biāo)受眾。

    社群媒體:

    在 LinkedIn、Twitter 和 Facebook 等平臺上分享您的作品集。
    使用相關(guān)主題標(biāo)籤來提高可見度。
    網(wǎng)路:

    與 Reddit、Stack Overflow 或 Dribbble 上的社群互動。
    參加虛擬或面對面的社交活動來展示您的作品。
    搜尋引擎優(yōu)化與內(nèi)容行銷:

    建立與您的領(lǐng)域相關(guān)的部落格以增加自然流量。
    使用相關(guān)關(guān)鍵字針對搜尋引擎優(yōu)化您的作品集。
    電子郵件簽名:

    在電子郵件簽名中包含指向您的作品集的鏈接,以被動地推廣它。
    結(jié)論
    創(chuàng)建優(yōu)雅的互動式作品集畫廊是一項有益的努力,它以專業(yè)且引人入勝的方式展示您的技能和專案。透過利用 HTML5、CSS3 和 JavaScript,您可以建立在數(shù)位領(lǐng)域脫穎而出的響應(yīng)式動態(tài)產(chǎn)品組合。

    探索更多我的作品:
    LinkedIn:皮耶-羅曼洛佩茲
    角鬥士之戰(zhàn):gladiatorsbattle.com
    DivWeb:divweb.fr
    推特:@GladiatorsBT
    JeanFernandsEtti:jeanfernandsetti.fr
    XavierFlabat:xavier-flabat.com
    請隨時透過我的社交媒體管道或訪問我的網(wǎng)站來了解有關(guān)我的項目和服務(wù)的更多資訊。我始終對合作和新機會持開放態(tài)度!

    祝您編碼愉快,祝您的作品好運! ??

    作者簡介
    Pierre-Romain Lopez 是一位充滿熱情的 Web 開發(fā)人員和設(shè)計師,對細節(jié)有著敏銳的洞察力,致力於創(chuàng)造引人入勝且使用者友好的數(shù)位體驗。 Pierre-Romain 擁有涵蓋網(wǎng)頁設(shè)計、平面設(shè)計和攝影的多元化產(chǎn)品組合,擅長透過程式碼和設(shè)計將創(chuàng)意願景變?yōu)??現(xiàn)實。

    以上是使用 HTMLCSS 和 JavaScript 建立優(yōu)雅的互動式作品集畫廊的詳細內(nèi)容。更多資訊請關(guān)注PHP中文網(wǎng)其他相關(guān)文章!

    本網(wǎng)站聲明
    本文內(nèi)容由網(wǎng)友自願投稿,版權(quán)歸原作者所有。本站不承擔(dān)相應(yīng)的法律責(zé)任。如發(fā)現(xiàn)涉嫌抄襲或侵權(quán)的內(nèi)容,請聯(lián)絡(luò)admin@php.cn

    熱AI工具

    Undress AI Tool

    Undress AI Tool

    免費脫衣圖片

    Undresser.AI Undress

    Undresser.AI Undress

    人工智慧驅(qū)動的應(yīng)用程序,用於創(chuàng)建逼真的裸體照片

    AI Clothes Remover

    AI Clothes Remover

    用於從照片中去除衣服的線上人工智慧工具。

    Clothoff.io

    Clothoff.io

    AI脫衣器

    Video Face Swap

    Video Face Swap

    使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

    熱工具

    記事本++7.3.1

    記事本++7.3.1

    好用且免費的程式碼編輯器

    SublimeText3漢化版

    SublimeText3漢化版

    中文版,非常好用

    禪工作室 13.0.1

    禪工作室 13.0.1

    強大的PHP整合開發(fā)環(huán)境

    Dreamweaver CS6

    Dreamweaver CS6

    視覺化網(wǎng)頁開發(fā)工具

    SublimeText3 Mac版

    SublimeText3 Mac版

    神級程式碼編輯軟體(SublimeText3)

    如何在JS中與日期和時間合作? 如何在JS中與日期和時間合作? Jul 01, 2025 am 01:27 AM

    JavaScript中的日期和時間處理需注意以下幾點:1.創(chuàng)建Date對像有多種方式,推薦使用ISO格式字符串以保證兼容性;2.獲取和設(shè)置時間信息可用get和set方法,注意月份從0開始;3.手動格式化日期需拼接字符串,也可使用第三方庫;4.處理時區(qū)問題建議使用支持時區(qū)的庫,如Luxon。掌握這些要點能有效避免常見錯誤。

    為什麼要將標(biāo)籤放在的底部? 為什麼要將標(biāo)籤放在的底部? Jul 02, 2025 am 01:22 AM

    PlacingtagsatthebottomofablogpostorwebpageservespracticalpurposesforSEO,userexperience,anddesign.1.IthelpswithSEObyallowingsearchenginestoaccesskeyword-relevanttagswithoutclutteringthemaincontent.2.Itimprovesuserexperiencebykeepingthefocusonthearticl

    什麼是在DOM中冒泡和捕獲的事件? 什麼是在DOM中冒泡和捕獲的事件? Jul 02, 2025 am 01:19 AM

    事件捕獲和冒泡是DOM中事件傳播的兩個階段,捕獲是從頂層向下到目標(biāo)元素,冒泡是從目標(biāo)元素向上傳播到頂層。 1.事件捕獲通過addEventListener的useCapture參數(shù)設(shè)為true實現(xiàn);2.事件冒泡是默認行為,useCapture設(shè)為false或省略;3.可使用event.stopPropagation()阻止事件傳播;4.冒泡支持事件委託,提高動態(tài)內(nèi)容處理效率;5.捕獲可用於提前攔截事件,如日誌記錄或錯誤處理。了解這兩個階段有助於精確控制JavaScript響應(yīng)用戶操作的時機和方式。

    如何減少JavaScript應(yīng)用程序的有效載荷大??? 如何減少JavaScript應(yīng)用程序的有效載荷大??? Jun 26, 2025 am 12:54 AM

    如果JavaScript應(yīng)用加載慢、性能差,問題往往出在payload太大,解決方法包括:1.使用代碼拆分(CodeSplitting),通過React.lazy()或構(gòu)建工具將大bundle拆分為多個小文件,按需加載以減少首次下載量;2.移除未使用的代碼(TreeShaking),利用ES6模塊機制清除“死代碼”,確保引入的庫支持該特性;3.壓縮和合併資源文件,啟用Gzip/Brotli和Terser壓縮JS,合理合併文件並優(yōu)化靜態(tài)資源;4.替換重型依賴,選用輕量級庫如day.js、fetch

    JavaScript模塊上的確定JS綜述:ES模塊與COMPORJS JavaScript模塊上的確定JS綜述:ES模塊與COMPORJS Jul 02, 2025 am 01:28 AM

    ES模塊和CommonJS的主要區(qū)別在於加載方式和使用場景。 1.CommonJS是同步加載,適用於Node.js服務(wù)器端環(huán)境;2.ES模塊是異步加載,適用於瀏覽器等網(wǎng)絡(luò)環(huán)境;3.語法上,ES模塊使用import/export,且必須位於頂層作用域,而CommonJS使用require/module.exports,可在運行時動態(tài)調(diào)用;4.CommonJS廣泛用於舊版Node.js及依賴它的庫如Express,ES模塊則適用於現(xiàn)代前端框架和Node.jsv14 ;5.雖然可混合使用,但容易引發(fā)問題

    如何在node.js中提出HTTP請求? 如何在node.js中提出HTTP請求? Jul 13, 2025 am 02:18 AM

    在Node.js中發(fā)起HTTP請求有三種常用方式:使用內(nèi)置模塊、axios和node-fetch。 1.使用內(nèi)置的http/https模塊無需依賴,適合基礎(chǔ)場景,但需手動處理數(shù)據(jù)拼接和錯誤監(jiān)聽,例如用https.get()獲取數(shù)據(jù)或通過.write()發(fā)送POST請求;2.axios是基於Promise的第三方庫,語法簡潔且功能強大,支持async/await、自動JSON轉(zhuǎn)換、攔截器等,推薦用於簡化異步請求操作;3.node-fetch提供類似瀏覽器fetch的風(fēng)格,基於Promise且語法簡單

    垃圾收集如何在JavaScript中起作用? 垃圾收集如何在JavaScript中起作用? Jul 04, 2025 am 12:42 AM

    JavaScript的垃圾回收機制通過標(biāo)記-清除算法自動管理內(nèi)存,以減少內(nèi)存洩漏風(fēng)險。引擎從根對像出發(fā)遍歷並標(biāo)記活躍對象,未被標(biāo)記的則被視為垃圾並被清除。例如,當(dāng)對像不再被引用(如將變量設(shè)為null),它將在下一輪迴收中被釋放。常見的內(nèi)存洩漏原因包括:①未清除的定時器或事件監(jiān)聽器;②閉包中對外部變量的引用;③全局變量持續(xù)持有大量數(shù)據(jù)。 V8引擎通過分代回收、增量標(biāo)記、並行/並發(fā)回收等策略優(yōu)化回收效率,降低主線程阻塞時間。開發(fā)時應(yīng)避免不必要的全局引用、及時解除對象關(guān)聯(lián),以提升性能與穩(wěn)定性。

    var vs Let vs const:快速JS綜述解釋器 var vs Let vs const:快速JS綜述解釋器 Jul 02, 2025 am 01:18 AM

    var、let和const的區(qū)別在於作用域、提升和重複聲明。 1.var是函數(shù)作用域,存在變量提升,允許重複聲明;2.let是塊級作用域,存在暫時性死區(qū),不允許重複聲明;3.const也是塊級作用域,必須立即賦值,不可重新賦值,但可修改引用類型的內(nèi)部值。優(yōu)先使用const,需改變變量時用let,避免使用var。

    See all articles