HTMLCSS實現異環網站,期末web作業

? ?

本網站是我在學習前端時敲得,僅供學習使用。

?這段代碼是一個完整的 HTML 網頁項目,包含 HTML、CSS 和 JavaScript 部分,用于構建一個名為 “異環” 的網頁。網頁具備頭部導航欄、主體視頻展示、圖片交互元素、音樂播放控制、視頻彈窗播放以及底部信息展示等功能。

代碼詳細分析

1. HTML 部分
<!DOCTYPE html>
<html lang="en"><head><meta charset="UTF-8" /><meta name="viewport" content="width=device-width, initial-scale=1.0" /><title>異環</title><!-- 谷歌字體鏈接 --><link rel="preconnect" href="https://fonts.googleapis.com" /><link rel="preconnect" href="https://fonts.gstatic.com" crossorigin /><link href="https://fonts.googleapis.com/css2?family=ZCOOL+QingKe+HuangYou&display=swap" rel="stylesheet" /><!-- CSS 鏈接 --><link rel="stylesheet" href="../css/index.css" />
</head><body><header><nav class="nav-wrapper"><section class="left"><img src="../png/NTE_logo.png" alt="NTE_logo" /></section><section class="middle"><ul><li><a href="./index.html" class="active">首頁</a></li><li><a href="./charater1.html">角色介紹</a></li><li><a href="./city.html">都市映像</a></li><li><a href="./qingbao.html">情報速遞</a></li><li><a href="./jiaru.html">加入我們</a></li></ul></section><section class="right"><div class="air"></div><div class="img" id="musicBtn"></div><audio id="music" src="../yh_gw_bgm.mp3" loop></audio></section></nav></header><main><div class="mainPartWrapper"><section class="mainVideo"><video src="../mp4/yh_bgv_20240704.mp4" loop autoplay muted></video></section><section class="left"><div class="NET"><img src="../png/indexNet.png" alt="NET" /></div></section><section class="middle"><div class="info1"></div><div class="img1"></div><div class="img2"></div></section><section class="video"><div><div class="img" id="videoTrigger"><video src="../mp4/3d3d139dbefb5bf8bc0fee2e1a2f5e06.mp4"></video></div></div></section><section class="taptap"><div class="img"><a href=""></a></div></section><section class="character"><div class="img"><a href="./charater1.html"><img src="../png/guide_role.png" alt="" /></a></div></section></div></main><!-- 視頻覆蓋層 --><div class="video-overlay" id="videoOverlay"><video id="centeredVideo" controls></video></div><footer><section class="wrapper"><div class="left"><ul><li class="item"><a href="#"></a></li><li class="item1"><a href="#"></a></li><li class="item2"><a href="#"></a></li><li class="item3"><a href="#"></a></li><li class="item4"><a href="#"></a></li><li class="item5"><a href="#"></a></li><li class="item6"><a href="#"></a></li><li class="item7"><a href="#"></a></li></ul></div><div class="middle"><img src="" alt="" /></div><div class="right"><div class="air"></div><div class="img"></div></div></section></footer><script>// 音樂控制const musicBtn = document.getElementById('musicBtn');const music = document.getElementById('music');// 初始狀態設為暫停music.pause();musicBtn.addEventListener('click', function () {if (music.paused) {music.play();this.style.backgroundPosition = '0 -4.31rem'; // 切換到播放狀態} else {music.pause();this.style.backgroundPosition = '0 0'; // 切換回暫停狀態}});// 視頻控制const videoTrigger = document.getElementById('videoTrigger');const videoOverlay = document.getElementById('videoOverlay');const centeredVideo = document.getElementById('centeredVideo');const smallVideo = videoTrigger.querySelector('video');videoTrigger.addEventListener('click', function () {centeredVideo.src = smallVideo.src;videoOverlay.style.display = 'flex';centeredVideo.play();});videoOverlay.addEventListener('click', function (e) {if (e.target === this) { // 只點擊覆蓋層時關閉centeredVideo.pause();videoOverlay.style.display = 'none';}});</script>
</body></html>
  • 頭部(<head>

    • 設置字符編碼為 UTF - 8,并配置視口以實現響應式設計。
    • 引入谷歌字體?ZCOOL QingKe HuangYou,為網頁提供獨特的字體樣式。
    • 鏈接外部 CSS 文件?index.css,用于定義網頁的樣式。
  • 主體(<body>

    • 頭部導航欄(<header>
      • 左側展示網站 logo 圖片。
      • 中間是導航菜單,包含首頁、角色介紹、都市映像、情報速遞和加入我們等鏈接。
      • 右側有一個音樂播放控制按鈕和一個音頻元素,音頻可循環播放。
    • 主體內容(<main>
      • 頂部有一個全屏循環播放的靜音視頻作為背景。
      • 包含多個部分,有圖片展示區域、視頻觸發區域、角色引導圖片等。
    • 視頻覆蓋層(.video - overlay:用于在點擊視頻觸發區域時彈出視頻播放窗口,視頻可控制播放。
    • 底部(<footer>:分為左、中、右三個部分,左側有多個圖標鏈接,中間預留圖片展示區域,右側有一個占位元素和一個圖片。
  • JavaScript 部分

    • 音樂控制:通過點擊音樂按鈕控制音樂的播放和暫停,同時切換按鈕的背景位置以顯示不同狀態。
    • 視頻控制:點擊視頻觸發區域,將小視頻的源復制到覆蓋層的視頻中,顯示覆蓋層并播放視頻;點擊覆蓋層空白處可關閉視頻。
    • 2. CSS 部分
    • * {margin: 0;padding: 0;box-sizing: border-box;font-family: "ZCOOL QingKe HuangYou", "Courier New", Courier, monospace;font-size: 1rem;font-weight: normal;
      }body {overflow: hidden;
      }body header {box-shadow: 2px 2px 2px 1px rgba(29, 29, 29, 0.5);
      }body header nav.nav-wrapper {width: 100%;display: flex;background-size: cover;background: #1d1d1d url(https://yh.wanmei.com/images/cover240718/header.png) no-repeat right top;height: 8.3vh;
      }body header nav.nav-wrapper section.left {display: flex;justify-content: space-around;flex: 2 1 100px;width: 20%;
      }body header nav.nav-wrapper section.left img {padding: 1rem;width: 40%;height: 110%;
      }body header nav.nav-wrapper section.middle {display: flex;flex: 7 1 700px;width: 70%;align-items: center;justify-content: center;
      }body header nav.nav-wrapper section.middle ul {width: 75%;display: flex;list-style-type: none;justify-content: space-around;
      }body header nav.nav-wrapper section.middle ul {position: relative;/* 為偽元素定位做準備 */z-index: 1;/* 確保內容在背景之上 */
      }/* 添加三個背景層作為偽元素 */
      body header nav.nav-wrapper section.middle ul::before,
      body header nav.nav-wrapper section.middle ul::after,
      body header nav.nav-wrapper section.middle ul li:first-child::before {content: "";position: absolute;top: 0;left: 0;width: 100%;height: 100%;pointer-events: none;/* 確保可以點擊下面的鏈接 */
      }body header nav.nav-wrapper section.middle ul li a {text-decoration: none;color: #a7a7a7;font-size: 1.3rem;
      }body header nav.nav-wrapper section.middle ul li a.active {color: aqua;font-size: 1.1rem;text-decoration: none;
      }body header nav.nav-wrapper section.right {display: flex;flex: 1 1 100px;width: 20%;justify-content: space-around;align-items: center;
      }body header nav.nav-wrapper section.right div.air {width: 5rem;height: 5rem;
      }body header nav.nav-wrapper section.right div.img {margin-left: -2rem;width: 4.31rem;height: 4.31rem;background-size: cover;background-image: url(../png/bgMusicSwitch.png);background-position: 0 0;cursor: pointer;transition: background-position 0.3s ease;
      }body main {position: relative;
      }body main div.mainPartWrapper {width: 100%;height: 80vh;
      }body main div.mainPartWrapper section.mainVideo {width: 100%;height: 100%;
      }body main div.mainPartWrapper section.mainVideo video {width: 100%;height: 100%;object-fit: cover;
      }body main div.mainPartWrapper section.left div.NET {top: 690px;left: 42px;position: absolute;width: 13%;
      }body main div.mainPartWrapper section.left div.NET img {width: 70%;
      }body main div.mainPartWrapper section.middle {position: absolute;width: 40vw;height: 20vh;top: 425px;left: 500px;
      }body main div.mainPartWrapper section.middle div.img1 {position: absolute;top: 74px;left: 180px;width: 70%;height: 15vh;background-image: url(../png/indexYyBtn.png);background-repeat: no-repeat;background-position: 0 0;background-size: cover;
      }body main div.mainPartWrapper section.middle div.img1:hover {background-position: 0 -152px;
      }body main div.mainPartWrapper section.video {width: 10vw;height: 10vh;
      }body main div.mainPartWrapper section.video div {width: 100%;height: 100%;
      }body main div.mainPartWrapper section.video div div.img {position: absolute;top: 450px;left: 1210px;width: 9%;height: 14vh;background-position: 0 -123px;background-image: url(../png/pvBtn.png);background-size: cover;cursor: pointer;
      }body main div.mainPartWrapper section.video div div.img video {width: 100%;height: 100%;display: none;
      }body main div.mainPartWrapper section.taptap div.img {position: absolute;top: 280px;left: 1850px;width: 17.4vh;height: 32vh;background-image: url(../png/tapAside.png);background-repeat: no-repeat;background-position: -171px 0;
      }body main div.mainPartWrapper section.taptap div.img:hover {background-position: 0 0;
      }body main div.mainPartWrapper section.character div.img {top: 690px;left: 1750px;position: absolute;width: 20%;
      }body main div.mainPartWrapper section.character div.img img {width: 70%;
      }body footer {width: 100%;height: 11.7vh;
      }body footer section.wrapper {display: flex;width: 100%;height: 100%;background-color: #1d1d1d;
      }body footer section.wrapper div.left {flex: 2 1 200px;
      }body footer section.wrapper div.left ul {display: flex;list-style-type: none;justify-content: space-between;}body footer section.wrapper div.left ul {position: relative;/* 為絕對定位的子元素建立參照 */height: 55px;/* 設置與圖標相同的高度 */margin-left: 50px;/* 初始左邊距 */
      }body footer section.wrapper div.left ul li {position: absolute;top: 25px;width: 55px;height: 55px;background-image: url(../otherPlatform.png);background-size: 498px 110px;
      }/* 各個圖標項的精確定位 */
      body footer section.wrapper div.left ul li.item {left: 0;background-position: -124px 0;
      }body footer section.wrapper div.left ul li.item:hover {background-position: -124px -55px;/* 修正懸停位置,應該是向下移動55px */
      }body footer section.wrapper div.left ul li.item1 {left: 70px;background-position: -58px 0;
      }body footer section.wrapper div.left ul li.item1:hover {background-position: -58px -55px;
      }body footer section.wrapper div.left ul li.item2 {left: 134px;background-position: 0 0;
      }body footer section.wrapper div.left ul li.item2:hover {background-position: 0 -55px;
      }body footer section.wrapper div.left ul li.item3 {left: 198px;background-position: -188px 0;
      }body footer section.wrapper div.left ul li.item3:hover {background-position: -188px -55px;
      }body footer section.wrapper div.left ul li.item4 {left: 262px;background-position: -252px 0;
      }body footer section.wrapper div.left ul li.item4:hover {background-position: -252px -55px;
      }body footer section.wrapper div.left ul li.item5 {left: 326px;background-position: -317px 0;
      }body footer section.wrapper div.left ul li.item5:hover {background-position: -317px -55px;
      }body footer section.wrapper div.left ul li.item6 {left: 390px;background-position: -380px 0;
      }body footer section.wrapper div.left ul li.item6:hover {background-position: -380px -55px;
      }body footer section.wrapper div.left ul li.item7 {left: 454px;background-position: -442px 0;
      }body footer section.wrapper div.left ul li.item7:hover {background-position: -442px -55px;
      }body footer section.wrapper div.middle {flex: 4 1 200px;background-image: url(../png/indexFoot.png);background-size: contain;margin-left: 100px;scale: 1.2;
      }body footer section.wrapper div.right {display: flex;flex: 2 1 200px;justify-content: space-around;align-items: center;
      }body footer section.wrapper div.right div.air {width: 10%;
      }body footer section.wrapper div.right div.img {width: 54%;height: 58%;background-image: url(../png/neverness.png);background-size: contain;
      }/* 視頻覆蓋層樣式 */
      .video-overlay {display: none;position: fixed;top: 0;left: 0;width: 100%;height: 100%;background-color: rgba(0, 0, 0, 0.8);justify-content: center;align-items: center;z-index: 1000;
      }.video-overlay video {max-width: 80%;max-height: 80%;outline: none;
      }

總結

這個網頁項目通過 HTML 構建頁面結構,CSS 實現頁面樣式和交互效果,JavaScript 實現音樂和視頻的控制功能。整體布局合理,交互豐富,能夠為用戶提供較好的瀏覽體驗。在實際使用時,需要確保圖片和音視頻文件的路徑正確,以保證網頁的正常顯示和功能實現。

效果如圖

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/web/76579.shtml
繁體地址,請注明出處:http://hk.pswp.cn/web/76579.shtml
英文地址,請注明出處:http://en.pswp.cn/web/76579.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

Oracle表的別名不能用as,列的別名可以用as

在 Oracle 數據庫中&#xff0c;?表的別名?和?列的別名?在使用 AS 關鍵字時確實有不同規則&#xff0c;以下是詳細說明&#xff1a; 1. 表的別名&#xff08;Table Alias&#xff09;? ?不支持 AS 關鍵字?&#xff0c;直接跟在表名后即可。?語法示例?&#xff1a; S…

【SAP ME 44】在 HANA DB中報廢SFC時的SHOP_ORDER表記錄鎖定

癥狀 SELECT…FROM SHOP_ORDER FOR UPDATE 在 SFC 報廢期間持有鎖,當同時調用數量較大時,可能會導致 HANA 數據庫出現大量鎖積壓。這有時會導致因等待 HANA 數據庫釋放“選擇更新”鎖而導致報廢 SFC 花費數分鐘。 HANA 數據庫日志中的示例: # begin PreparedStatement_ex…

Vscode開發Vue項目NodeJs啟動報錯處理

文章目錄 背景一、npm啟動報錯報錯信息定位原因處理方案第一步、下載安裝高版本 二、node 無法識別報錯信息處理方案定位原因第一步、檢測環境變量第二步、重新開啟界面 背景 使用Vscode開發Vue項目&#xff0c;使用到NodeJs&#xff0c;記錄出現的問題及處理方案&#xff0c;…

破局遺留系統!AI自動化重構:從靜態方法到Spring Bean注入實戰

在當今快速發展的軟件行業中,許多企業都面臨著 Java 遺留系統的維護和升級難題。這些老舊系統往往采用了大量靜態方法,隨著業務的不斷發展,其局限性日益凸顯。而飛算 JavaAI 作為一款強大的 AI 工具,為 Java 遺留系統的重構提供了全新的解決方案,能夠實現從靜態方法到 Spring B…

2025媽媽杯數學建模C題完整分析論文(共36頁)(含模型建立、可運行代碼、數據)

2025 年第十五屆 MathorCup 數學建模C題完整分析論文 目錄 摘 要 一、問題分析 二、問題重述 三、模型假設 四、 模型建立與求解 4.1問題1 4.1.1問題1思路分析 4.1.2問題1模型建立 4.1.3問題1代碼&#xff08;僅供參考&#xff09; 4.1.4問題1求解結果&#xff08;僅…

【Python爬蟲詳解】第一篇:Python爬蟲入門指南

什么是網絡爬蟲&#xff1f; 網絡爬蟲&#xff08;Web Crawler&#xff09;是一種自動獲取網頁內容的程序。它可以訪問網站&#xff0c;抓取頁面內容&#xff0c;并從中提取有價值的數據。在信息爆炸的時代&#xff0c;爬蟲技術可以幫助我們高效地收集、整理和分析互聯網上的海…

【JavaWeb后端開發02】SpringBootWeb + Https協議

課程內容&#xff1a; SpringBootWeb 入門 Http協議 SpringBootWeb案例 分層解耦 文章目錄 1. SpringBootWeb入門1.1 概述1.2 入門程序1.2.1 需求1.2.2 開發步驟1.2.3 常見問題 1.3 入門解析 2. HTTP協議2.1 HTTP概述2.1.1 介紹2.1.2 特點 2.2 HTTP請求協議2.2.1 介紹2.2.2…

MATLAB 控制系統設計與仿真 - 37

范數魯棒控制器的設計 魯棒控制器的設計 根據雙端子狀態方程對象模型結構&#xff0c;控制器設計的目標是找到一個控制器K(s),它能保證閉環系統的范數限制在一個給定的小整數下&#xff0c;即 這時控制器的狀態方程為&#xff1a; 其中X與Y分別為下面兩個代數Riccati方程的解…

依賴沖突,缺失插件導致無法啟動項目 強制安裝命令(npm install --legacy-peer-deps)

小白終成大白 文章目錄 小白終成大白前言總結 前言 運維工程師說搞一個自動化打包流程 在服務器裝了hbuilder 找前端來啟動項目 我沒啟動起來 … 啟動報錯 failed to load config from D:\zhuque-uniapp\vite.config.js 16:17:31.601 error when starting dev server: 16:17:3…

數據戰略新范式:從中臺沉淀到服務覺醒,SQL2API 如何重塑數據價值鏈條?

一、數據中臺退燒&#xff1a;從 “戰略神話” 到 “現實拷問” 曾幾何時&#xff0c;數據中臺被視為企業數字化轉型的 “萬能解藥”&#xff0c;承載著統一數據資產、打破業務壁壘的厚望。然而&#xff0c;大量實踐暴露出其固有缺陷&#xff1a;某零售企業投入 500 萬元建設中…

警惕阿里云中的yum update操作不當導致:/sbin/init被清空導致Linux無法正常啟動

由于使用阿里云進行部署測試&#xff0c;因而會對yum update進行操作&#xff0c;這兩天更新了systemd-239-82.0.3.4.al8.2.x86_64&#xff0c;但存在報錯&#xff0c;然后進行yum history undo和清空yum cache&#xff0c;但出現操作Linux命令行無效。具體來說&#xff0c;幾個…

論文閱讀:2023 ICLR Safe RLHF: Safe Reinforcement Learning from Human Feedback

總目錄 大模型安全相關研究:https://blog.csdn.net/WhiffeYF/article/details/142132328 Safe RLHF: Safe Reinforcement Learning from Human Feedback 安全 RLHF:通過人類反饋進行安全強化學習 https://arxiv.org/pdf/2310.12773 https://github.com/PKU-Alignment/safe…

android rom打包解包工具,Android ROM定制:boot.img、recovery解包打包

安卓boot.img和recovery.img解析與修改指南 安卓映像文件結構解析 大家都知道安卓的核心更換是在boot.img里面&#xff0c;那么如何在Windows下解開它呢&#xff1f;這里介紹一個實用的方法。 首先需要獲取bootimg.exe工具&#xff0c;這個工具最初是為華為設備開發的&#…

cdp-(Chrome DevTools Protocol) browserscan檢測原理逆向分析

https://www.browserscan.net/zh/bot-detection 首先,打開devtools后訪問網址,檢測結果網頁顯示紅色Robot,標簽插入位置,確定斷點位置可以hook該方法,也可以使用插件等方式找到這個位置,本篇不討論. Robot標簽是通過insertBefore插入的. 再往上追棧可以發現一個32長度數組,里面…

PostgreSQL 通過 copy 命令導入幾何數據 及 通過 CopyManager.copyIn() 導入幾何數據

COPY命令介紹 copy是postgresql提供的一個專門用于快速導入導出數據的命令,通常用于從文件(TXT、CSV等)或標準輸入輸出中讀取或寫入數據。適合批量導入導出數據,速度快。 默認情況下,如果在處理過程中遇到錯誤,COPY將失敗。 COPY只能用于表,不能用于視圖!!! COPY…

常用的幾種 Vue 父子組件傳值方式

1. 父組件向子組件傳值(props) 父組件代碼:Parent.vue <template><div><h2>父組件</h2><Child :parent-msg="parentMsg" /></div> </template><script> import Child from ./Child.vue;export default {componen…

【1】云原生,kubernetes 與 Docker 的關系

Kubernetes&#xff1f;K8s&#xff1f; Kubernetes經常被寫作K8s。其中的數字8替代了K和s中的8個字母——這一點倒是方便了發推&#xff0c;也方便了像我這樣懶惰的人。 什么是云原生&#xff1f; 云原生&#xff1a; 它是一種構建和運行應用程序的方法&#xff0c;它包含&am…

Eureka搭建

1.注冊中心server端 1.1.引入依賴 <dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-security</artifactId> </dependency> <dependency><groupId>org.springframework.cloud</…

2025年最新版動漫短劇系統開發小程序app教程,源碼部署上線

以下是動漫短劇系統開發上線的詳細教程&#xff0c;包含從0到1的全流程&#xff1a; 一、需求分析&#xff08;關鍵&#xff1a;明確核心功能&#xff09; 核心功能清單&#xff1a; 用戶端&#xff1a;短視頻瀏覽、彈幕評論、收藏/點贊、創作者關注、付費訂閱。創作者端&am…

集成學習基礎應用實踐

集成學習簡介 學習目標&#xff1a; 1.知道集成學習是什么&#xff1f; 2.了解集成學習的分類 3.理解bagging集成的思想 4.理解boosting集成的思想 知道】集成學習是什么&#xff1f; 集成學習是機器學習中的一種思想&#xff0c;它通過多個模型的組合形成一個精度更高的…