Web前端期末大作業(yè)-重慶旅游景區(qū)網(wǎng)頁設(shè)計(HTML+CSS+JS)

一、??作品介紹

HTML實例網(wǎng)頁代碼, 本實例適合于初學(xué)HTML的同學(xué)郭卫。該實例里面有設(shè)置了css的樣式設(shè)置,有div的樣式格局,這個實例比較全面桨嫁,有助于同學(xué)的學(xué)習(xí),本文將介紹如何通過從頭開始設(shè)計個人網(wǎng)站并將其轉(zhuǎn)換為代碼的過程來實踐設(shè)計植兰。


二、??作品效果

??視頻演示

https://live.csdn.net/v/embed/239926

(title-E85JP 重慶旅游7頁 帶js 帶輪播)]

?? 截圖演示

07.png
06.png
05.png
04.png
03.png
02.png
01.png


三璃吧、?? 作品代碼

??HTML代碼


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>重慶旅游</title>
    <link rel="stylesheet" type="text/css" href="css/style.css" />
    <link rel="stylesheet" href="css/swiper.css" />
    <link rel="stylesheet" href="css/font/iconfont.css" />
  </head>

  <body>
    <div id="page">
      <!-- 輪播圖主體 -->
      <div class="swipe" id="swipe">
        <!-- 模糊背景 -->
        <div class="bg" id="swipe_bg"></div>
        <!-- 圖片區(qū)域 -->
        <section>
          <!-- 圖片顯示 -->
          <div class="img-box" id="swipe_img_box">
            <a href="#" class="link" id="swipe_link">
              <img src="images/banner.jpg" alt="" class="img" id="swipe_img" />
            </a>
          </div>
          <!-- 指示點 -->
          <div class="select" id="swipe_select"></div>
          <!-- 左側(cè)翻頁按鈕 -->
          <div class="btn left" id="swipe_btn_left">
            <!-- 字體圖標(biāo):左箭頭 -->
            <i class="iconfont icon-zuojiantou" aria-hidden="true"></i>
          </div>
          <!-- 右側(cè)翻頁按鈕 -->
          <div class="btn right" id="swipe_btn_right">
            <!-- 字體圖標(biāo):右箭頭 -->
            <i class="iconfont icon-youjiantou" aria-hidden="true"></i>
          </div>
        </section>
      </div>
      <div class="nav">
        <ul>
          <li><a href="index.html">首頁</a></li>
          <li><a href="index_1.html">美食</a></li>
          <li><a href="index_2.html">景點</a></li>
          <li><a href="index_3.html">酒店</a></li>
          <li><a href="index_1.1.html">攻略</a></li>
        </ul>
      </div>

      <div class="tuce">
        <h1>重慶</h1>
        <h2>
          美食  景點 特產(chǎn) 民族 <span class="yq">友情鏈接:<a  target="_blank">重慶市旅游政務(wù)網(wǎng)</a></span>
        </h2>
        <div class="left_in"><img src="images/d1.png" width="410" /><img src="images/d2.jpg" width="410" height="310" /></div>
        <div class="right_in">
          <h3>院校</h3>
          <ul>
            <li>
              <a href="#"><img src="images/cp_1.jpg" /></a>
              <p>
                重慶大學(xué)<br />
                創(chuàng)辦于1929年 <br />
                學(xué)校占地面積5212畝
              </p>
            </li>
            <li>
              <a href="#"><img src="images/cp_2.jpg" /></a>
              <p>
                重慶醫(yī)科大學(xué) <br />
                創(chuàng)建于1956年 <br />
                “211”院校
              </p>
            </li>

            <li>
              <img src="images/cp_3.jpg" border="0" usemap="#Map" />
              <map name="Map" id="Map">
                <area shape="poly" coords="65,134,124,75,178,52,222,130,136,192,53,181" href="#" />
              </map>
              <p>
                重慶郵電大學(xué) <br />
                創(chuàng)辦于1950年3月 <br />
                開設(shè)有53個本科專業(yè)
              </p>
            </li>

            <li>
              <img src="images/cp_4.jpg" border="0" usemap="#Map2" />
              <map name="Map2" id="Map2"><area shape="circle" coords="159,148,96" href="#" /></map>
              <p>
                重慶工商大學(xué) <br />
                始創(chuàng)于1952年 <br />
                是入選“小211工程“的高校之一
              </p>
            </li>
          </ul>
        </div>
      </div>

      <div class="footer">
        <p>重慶旅游</p>
      </div>
    </div>
  </body>
  <script>
    // 當(dāng)前輪播圖編號
    let current_index = -1
    // 自動輪播定時器
    let swipe_timer = null
    // 輪播圖的圖片地址與跳轉(zhuǎn)鏈接
    let links = [
      { image: 'images/banner.jpg', target: '#1' },
      { image: 'images/d2.jpg', target: '#2' },
      { image: 'images/s.jpg', target: '#3' }
    ]

    // 需要操作到的元素
    let swipe = document.getElementById('swipe')
    let swipe_bg = document.getElementById('swipe_bg')
    let swipe_img_box = document.getElementById('swipe_img_box')
    let swipe_link = document.getElementById('swipe_link')
    let swipe_img = document.getElementById('swipe_img')
    let swipe_select = document.getElementById('swipe_select')
    let swipe_btn_left = document.getElementById('swipe_btn_left')
    let swipe_btn_right = document.getElementById('swipe_btn_right')

    // 事件
    // 切換圖片
    let select = (index) => {
      // 停止播放
      stop()
      // 轉(zhuǎn)數(shù)字
      index = Number(index)
      // 越界超過最大數(shù)量,直接返回
      if (index >= links.length) {
        return
      }
      // 選中當(dāng)前已選中的,直接返回
      if (current_index == index) {
        return
      }
      // 取消當(dāng)前指示點的選中狀態(tài)
      if (current_index > -1) {
        swipe_select.children[current_index].classList.remove('checked')
      }
      // 變更當(dāng)前輪播圖的編號
      current_index = index
      // 找到當(dāng)前元素
      let current_link = links[current_index]
      // 背景變化
      swipe_bg.style.backgroundImage = 'url(' + current_link.image + ')'
      // 前景變化
      swipe_img.setAttribute('src', current_link.image)
      // 鏈接變化
      swipe_link.setAttribute('href', current_link.target)
      // 增加新的指示點的選中狀態(tài)
      swipe_select.children[current_index].classList.add('checked')
    }
    // 自動切換圖片
    let autoSelect = (index) => {
      // 轉(zhuǎn)數(shù)字
      index = Number(index)
      // 越界超過最大數(shù)量楣导,直接返回
      if (index >= links.length) {
        return
      }
      // 選中當(dāng)前已選中的,直接返回
      if (current_index == index) {
        return
      }
      // 取消當(dāng)前指示點的選中狀態(tài)
      swipe_select.children[current_index].classList.remove('checked')
      // 變更當(dāng)前輪播圖的編號
      current_index = index
      // 找到當(dāng)前元素
      let current_link = links[current_index]
      // 前景圖片
      // 第一步調(diào)整過渡時間
      swipe_img.style.transition = 'opacity 0.5s ease-in 0s'
      // 第二步調(diào)整不透明度為0.2
      swipe_img.style.opacity = 0.2
      // 第三步延遲變換img圖片畜挨,并重新定義透明度以及過渡時間和過渡方式
      setTimeout(() => {
        // 背景變化
        swipe_bg.style.backgroundImage = 'url(' + current_link.image + ')'
        // 前景變化
        swipe_img.setAttribute('src', current_link.image)
        // 鏈接變化
        swipe_link.setAttribute('href', current_link.target)
        // 不透明度變化
        swipe_img.style.transition = 'opacity 0.7s ease-out 0s'
        swipe_img.style.opacity = 1
        // 增加新的指示點選中狀態(tài)
        // 如果已經(jīng)通過手動點擊了筒繁,選中則此處不再執(zhí)行
        if (!document.querySelector('.swipe .checked')) {
          swipe_select.children[current_index].style.transition = 'background-color 0.5s'
          swipe_select.children[current_index].classList.add('checked')
        }
      }, 500)
    }
    // 播放
    let play = () => {
      // 3秒切換一次
      swipe_timer = setInterval(() => {
        // 設(shè)置新的index
        let index = current_index + 1
        // 右翻越界,切到第一張
        if (index >= links.length) {
          index = 0
        }
        // 加載新圖片(這里選擇自動巴元,增加切換效果)
        autoSelect(index)
      }, 3000)
    }
    // 停止
    let stop = () => {
      if (swipe_timer) {
        clearInterval(swipe_timer)
        swipe_timer = null
      }
    }
    // 初始化
    let init = () => {
      for (let i = 0; i < links.length; i++) {
        // 創(chuàng)建a元素
        let item = document.createElement('a')
        // 修改屬性
        item.setAttribute('class', 'item')
        item.setAttribute('href', '#')
        item.setAttribute('data-index', i)
        // 追加元素
        swipe_select.appendChild(item)
      }
      // 默認(rèn)第一張
      select(0)
      // 綁定各個事件并開始輪播
      bind()
      play()
    }
    // 綁定
    let bind = () => {
      // 左翻事件監(jiān)聽
      swipe_btn_left.addEventListener('click', () => {
        // 設(shè)置新的index
        let index = current_index - 1
        // 左翻越界毡咏,切到最后一張
        if (index < 0) {
          index = links.length - 1
        }
        // 加載新圖片
        select(index)
        play()
      })
      // 右翻事件監(jiān)聽
      swipe_btn_right.addEventListener('click', () => {
        // 設(shè)置新的index
        let index = current_index + 1
        // 右翻越界,切到第一張
        if (index >= links.length) {
          index = 0
        }
        // 加載新圖片
        select(index)
        play()
      })
      // 循環(huán)綁定指示器點擊事件
      for (const key in swipe_select.children) {
        if (swipe_select.children.hasOwnProperty(key)) {
          const element = swipe_select.children[key]
          element.addEventListener('click', (e) => {
            // 取消默認(rèn)點擊跳轉(zhuǎn)
            e.preventDefault()
            // 跳轉(zhuǎn)到當(dāng)前指示點中data-index所指定的圖片
            select(e.target.dataset.index)
          })
        }
      }
    }
    // 頁面加載完畢逮刨,執(zhí)行初始化
    window.addEventListener('load', () => {
      init()
    })
  </script>
</html>




??CSS代碼

@charset "utf-8";
/* CSS Document */
body, html, div, blockquote, img, label, p, h1, h2, h3, h4, h5, h6, pre, ul, ol,
li, dl, dt, dd, form, a, fieldset, input, th, td
{margin: 0; padding: 0; border: 0; outline: none;}
body {  font-family: "微軟雅黑";font-size: 14px;color:#000000;line-height: 20px;text-align:left; background:url(../images/bej.jpg);}
td,th {font-family: "微軟雅黑";font-size: 12px;color: #000000;}
a {color: #000000;} 
A:link {TEXT-DECORATION: none;} 
A:visited {TEXT-DECORATION: none;}

ul,li{list-style-type:none;}
.clearit{clear:both;}
#page{width:980px; margin:0 auto; background: rgba(255,255,255, 0.5 )}
.nav{width:980px; height:40px; line-height:40px; text-align:center; background:#56b2e5;}
.nav ul li{width:120px; float:left; margin-left:40px; display:inline; font-size:14px;}
.nav ul li a{color:#FFFFFF; font-size: 16px}
.nav ul li A:hover {color:#2059a6}
.zuo{width:400px; float:left;}
.you{width:540px; float:right; font-size:14px; font-family:"微軟雅黑"; line-height:26px; padding:0 10px;}
.jieshao{width:960px; padding:10px; background:#FFFFFF;}
.tuce h2{font-size:14px; line-height:24px; color: #000; font-weight:bold; text-align:left; border-bottom:2px solid  #CCC; margin-bottom:20px;}
.tuce{ width:960px; padding:0 10px; overflow:hidden;}
.tuce p{padding-top:5px; font-size:14px; line-height:30px;}
.left_in{ width:410px; float:left; overflow:hidden; margin-right:15px;}
.left_in img {margin-top:10px;}
.right_in{ width:530px; float:right}
.right_in ul li{ width:240px; margin:10px; background:#FFFFFF; float:left; }
.right_in ul li img{ width:240px; border-bottom:1px solid #CCC; }
.right_in ul li p{ padding:10px; color:#666;}

.footer{background:#56b2e5; margin-top:10px;} 
.footer p{text-align:center;padding:20px 0; color:#FFFFFF;}
.xinxi{width:960px; padding:10px; background:#FFFFFF;}

.center_in{ width:980px; margin:0 auto;}
.center_in ul li{ width:220px; margin:10px; background:#FFFFFF; float:left; }
.center_in ul li img{ width:220px; border-bottom:1px solid #CCC; }
.center_in ul li p{ padding:10px; color:#666;}

.center_left{ width:500px; float:left;}
.center_right{ width:450px; float:right; line-height:30px;}


.yq{ float:right; color:#666}
h1{ font-family:"微軟雅黑"; line-height:80px;}


.ao { margin-right:30px; line-height:40px; }







四呕缭、??更多源碼

【干貨分享】自學(xué)編程的小伙伴可以前往我的 gitee 倉庫(持續(xù)更新中...)

??【web學(xué)習(xí)指南】從web基礎(chǔ)、計算機基礎(chǔ)到前端常用框架的教程修己,涵蓋前端大部分必備知識(學(xué)習(xí)指南 + 技術(shù)文章 + 資源分享)

Gitee倉庫地址(來個Star吧~): https://gitee.com/zhanyuqiu2022/my-app

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末恢总,一起剝皮案震驚了整個濱河市,隨后出現(xiàn)的幾起案子睬愤,更是在濱河造成了極大的恐慌片仿,老刑警劉巖,帶你破解...
    沈念sama閱讀 217,509評論 6 504
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件尤辱,死亡現(xiàn)場離奇詭異砂豌,居然都是意外死亡,警方通過查閱死者的電腦和手機啥刻,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 92,806評論 3 394
  • 文/潘曉璐 我一進店門奸鸯,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人可帽,你說我怎么就攤上這事娄涩。” “怎么了映跟?”我有些...
    開封第一講書人閱讀 163,875評論 0 354
  • 文/不壞的土叔 我叫張陵蓄拣,是天一觀的道長。 經(jīng)常有香客問我努隙,道長球恤,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 58,441評論 1 293
  • 正文 為了忘掉前任荸镊,我火速辦了婚禮咽斧,結(jié)果婚禮上堪置,老公的妹妹穿的比我還像新娘。我一直安慰自己张惹,他們只是感情好舀锨,可當(dāng)我...
    茶點故事閱讀 67,488評論 6 392
  • 文/花漫 我一把揭開白布。 她就那樣靜靜地躺著宛逗,像睡著了一般坎匿。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上雷激,一...
    開封第一講書人閱讀 51,365評論 1 302
  • 那天替蔬,我揣著相機與錄音,去河邊找鬼屎暇。 笑死承桥,一個胖子當(dāng)著我的面吹牛,可吹牛的內(nèi)容都是我干的恭垦。 我是一名探鬼主播快毛,決...
    沈念sama閱讀 40,190評論 3 418
  • 文/蒼蘭香墨 我猛地睜開眼,長吁一口氣:“原來是場噩夢啊……” “哼番挺!你這毒婦竟也來了唠帝?” 一聲冷哼從身側(cè)響起,我...
    開封第一講書人閱讀 39,062評論 0 276
  • 序言:老撾萬榮一對情侶失蹤玄柏,失蹤者是張志新(化名)和其女友劉穎襟衰,沒想到半個月后,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體粪摘,經(jīng)...
    沈念sama閱讀 45,500評論 1 314
  • 正文 獨居荒郊野嶺守林人離奇死亡瀑晒,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 37,706評論 3 335
  • 正文 我和宋清朗相戀三年,在試婚紗的時候發(fā)現(xiàn)自己被綠了徘意。 大學(xué)時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片苔悦。...
    茶點故事閱讀 39,834評論 1 347
  • 序言:一個原本活蹦亂跳的男人離奇死亡,死狀恐怖椎咧,靈堂內(nèi)的尸體忽然破棺而出玖详,到底是詐尸還是另有隱情,我是刑警寧澤勤讽,帶...
    沈念sama閱讀 35,559評論 5 345
  • 正文 年R本政府宣布蟋座,位于F島的核電站,受9級特大地震影響脚牍,放射性物質(zhì)發(fā)生泄漏向臀。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點故事閱讀 41,167評論 3 328
  • 文/蒙蒙 一诸狭、第九天 我趴在偏房一處隱蔽的房頂上張望券膀。 院中可真熱鬧君纫,春花似錦、人聲如沸三娩。這莊子的主人今日做“春日...
    開封第一講書人閱讀 31,779評論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽雀监。三九已至,卻和暖如春眨唬,著一層夾襖步出監(jiān)牢的瞬間会前,已是汗流浹背。 一陣腳步聲響...
    開封第一講書人閱讀 32,912評論 1 269
  • 我被黑心中介騙來泰國打工匾竿, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留瓦宜,地道東北人。 一個月前我還...
    沈念sama閱讀 47,958評論 2 370
  • 正文 我出身青樓岭妖,卻偏偏與公主長得像临庇,于是被迫代替她去往敵國和親。 傳聞我的和親對象是個殘疾皇子昵慌,可洞房花燭夜當(dāng)晚...
    茶點故事閱讀 44,779評論 2 354

推薦閱讀更多精彩內(nèi)容