若是須要查看最終代碼,請移步小編的GitHubjavascript
網址以下:https://dig.chouti.com/css
(此處的寫法,都是本身剛開始編程說的,轉眼間6個月過去了,再回頭看看,感慨良多,本身打算再寫一遍,實現更多的功能)html
這裏上傳一個本身作的抽屜新熱榜的小項目,這個主要是前端知識的應用,作的和原樣還有點差距,可是必定會更新的,但願本身從這個項目中學到知識,並對css和html的相關應用更加熟練。前端
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> <link type="text/css" rel="stylesheet" href="chouti.css"> <div class="head-box"> <div class="head-content"> <a href="#" class="logo"></a> <div class="action-menu"> <a href="#" class="tb active">所有</a> <a href="#" class="tb">42區</a> <a href="#" class="tb">段子</a> <a href="#" class="tb">圖片</a> <a href="#" class="tb">挨踢1024</a> <a href="#" class="tb">你問我答</a> </div> <div class="key-search"> <form action="/" method="post"> <input type="text" class="search-text" autocomplete="off"> <a href="#" class="i"> <span class="ico"></span> </a> </form> </div> <div class="action-nav"> <a href="#" class="register-btn">註冊</a> <a href="#" class="login-btn">登陸</a> </div> <div class="footer-band"> </div> </div> </div> <div class="main-content-box"> <div class="main-content"> <div class="content-L"> <div class="top-area"> <div class="child-nav"> <a href="#" class="hotbtn active icons" >最新</a> <a href="#" class="newbtn" >最新</a> <a href="#" class="personbtn" >人類發佈</a> </div> <div class="sort-nav"> <a href="#" class="sortbtn active">即時排序</a> <a href="#" class="newbtn">24小時</a> <a href="#" class="newbtn">3天</a> </div> <a href="#" class="publish-btn"> <span class="n2">發佈</span> </a> </div> <div class="content-list"> <div class="item"> <div class="new-pic"> <img src="news.jpg" alt="抽屜新熱榜"> </div> <div class="new-content"> <div class="part1"> <a href="#" class="show-content" target="_blank"> 普京31日接見俄冰球運動員【環球時報-環球網報道記者趙覺珵】"原諒咱們沒能保護大家免受(興奮劑醜聞的)傷害",俄羅斯總統普京31日對即將前往平昌參加冬奧會的俄羅斯運動員說出了這樣一句使人動容的話。國際奧委會此前以「系統性操縱反興奮劑工 </a> <span class="content-source">-ww4.sinaimg.com</span> <a href="#" class="n2"> <span class="content-kend">42區</span> </a> </div> <div class="part2"> <a href="#" class="recommend" title="推薦"> <span class="hand-icon icon-recommend"></span> <b>4</b> </a> <a href="javascript:" class="discuss"> <span class="hand-icon icon-discuss"></span> <b>5</b> </a> <a href="javascript:" class="collect" title="加入私藏"> <span class="hand-icon icon-collect"></span> <b>私藏</b> </a> <a href="#" class="user-a "> <span> <img src="13.png"> </span> <b>亂太郎</b> <span class="left time-into"> <a class="time-a" href="#" target="_blank"> <b>4分鐘前</b> </a> <i>入熱榜</i> </span> <span class="share-site-to"> <i>分享到</i> <span class="share-icon"> <a class="icon-sina" title="分享到新浪微博" href="#"></a> <a class="icon-douban" title="分享到豆瓣" href="#"></a> <a class="icon-qqzone" title="分享到QQ空間" href="#"></a> <a class="icon-tenxun" title="分享到騰訊" href="#"></a> <a class="icon-renren" title="分享到人人網" href="#"></a> <!--<a class="share-none"></a>--> </span> </span> </a> </div> </div> </div> <div class="item"> <div class="new-pic"> <img src="news.jpg" alt="抽屜新熱榜"> </div> <div class="new-content"> <div class="part1"> <a href="#" class="show-content" target="_blank"> 普京31日接見俄冰球運動員【環球時報-環球網報道記者趙覺珵】"原諒咱們沒能保護大家免受(興奮劑醜聞的)傷害",俄羅斯總統普京31日對即將前往平昌參加冬奧會的俄羅斯運動員說出了這樣一句使人動容的話。國際奧委會此前以「系統性操縱反興奮劑工 </a> <span class="content-source">-ww4.sinaimg.com</span> <a href="#" class="n2"> <span class="content-kend">42區</span> </a> </div> <div class="part2"> <a href="#" class="recommend" title="推薦"> <span class="hand-icon icon-recommend"></span> <b>4</b> </a> <a href="javascript:" class="discuss"> <span class="hand-icon icon-discuss"></span> <b>5</b> </a> <a href="javascript:" class="collect" title="加入私藏"> <span class="hand-icon icon-collect"></span> <b>私藏</b> </a> <a href="#" class="user-a "> <span> <img src="13.png"> </span> <b>亂太郎</b> <span class="left time-into"> <a class="time-a" href="#" target="_blank"> <b>4分鐘前</b> </a> <i>入熱榜</i> </span> <span class="share-site-to"> <i>分享到</i> <span class="share-icon"> <a class="icon-sina" title="分享到新浪微博" href="#"></a> <a class="icon-douban" title="分享到豆瓣" href="#"></a> <a class="icon-qqzone" title="分享到QQ空間" href="#"></a> <a class="icon-tenxun" title="分享到騰訊" href="#"></a> <a class="icon-renren" title="分享到人人網" href="#"></a> <!--<a class="share-none"></a>--> </span> </span> </a> </div> </div> </div> <div class="item"> <div class="new-pic"> <img src="news.jpg" alt="抽屜新熱榜"> </div> <div class="new-content"> <div class="part1"> <a href="#" class="show-content" target="_blank"> 普京31日接見俄冰球運動員【環球時報-環球網報道記者趙覺珵】"原諒咱們沒能保護大家免受(興奮劑醜聞的)傷害",俄羅斯總統普京31日對即將前往平昌參加冬奧會的俄羅斯運動員說出了這樣一句使人動容的話。國際奧委會此前以「系統性操縱反興奮劑工 </a> <span class="content-source">-ww4.sinaimg.com</span> <a href="#" class="n2"> <span class="content-kend">42區</span> </a> </div> <div class="part2"> <a href="#" class="recommend" title="推薦"> <span class="hand-icon icon-recommend"></span> <b>4</b> </a> <a href="javascript:" class="discuss"> <span class="hand-icon icon-discuss"></span> <b>5</b> </a> <a href="javascript:" class="collect" title="加入私藏"> <span class="hand-icon icon-collect"></span> <b>私藏</b> </a> <a href="#" class="user-a "> <span> <img src="13.png"> </span> <b>亂太郎</b> <span class="left time-into"> <a class="time-a" href="#" target="_blank"> <b>4分鐘前</b> </a> <i>入熱榜</i> </span> <span class="share-site-to"> <i>分享到</i> <span class="share-icon"> <a class="icon-sina" title="分享到新浪微博" href="#"></a> <a class="icon-douban" title="分享到豆瓣" href="#"></a> <a class="icon-qqzone" title="分享到QQ空間" href="#"></a> <a class="icon-tenxun" title="分享到騰訊" href="#"></a> <a class="icon-renren" title="分享到人人網" href="#"></a> <!--<a class="share-none"></a>--> </span> </span> </a> </div> </div> </div> <div class="item"> <div class="new-pic"> <img src="news.jpg" alt="抽屜新熱榜"> </div> <div class="new-content"> <div class="part1"> <a href="#" class="show-content" target="_blank"> 普京31日接見俄冰球運動員【環球時報-環球網報道記者趙覺珵】"原諒咱們沒能保護大家免受(興奮劑醜聞的)傷害",俄羅斯總統普京31日對即將前往平昌參加冬奧會的俄羅斯運動員說出了這樣一句使人動容的話。國際奧委會此前以「系統性操縱反興奮劑工 </a> <span class="content-source">-ww4.sinaimg.com</span> <a href="#" class="n2"> <span class="content-kend">42區</span> </a> </div> <div class="part2"> <a href="#" class="recommend" title="推薦"> <span class="hand-icon icon-recommend"></span> <b>4</b> </a> <a href="javascript:" class="discuss"> <span class="hand-icon icon-discuss"></span> <b>5</b> </a> <a href="javascript:" class="collect" title="加入私藏"> <span class="hand-icon icon-collect"></span> <b>私藏</b> </a> <a href="#" class="user-a "> <span> <img src="13.png"> </span> <b>亂太郎</b> <span class="left time-into"> <a class="time-a" href="#" target="_blank"> <b>4分鐘前</b> </a> <i>入熱榜</i> </span> <span class="share-site-to"> <i>分享到</i> <span class="share-icon"> <a class="icon-sina" title="分享到新浪微博" href="#"></a> <a class="icon-douban" title="分享到豆瓣" href="#"></a> <a class="icon-qqzone" title="分享到QQ空間" href="#"></a> <a class="icon-tenxun" title="分享到騰訊" href="#"></a> <a class="icon-renren" title="分享到人人網" href="#"></a> <!--<a class="share-none"></a>--> </span> </span> </a> </div> </div> </div> <div class="item"> <div class="new-pic"> <img src="news.jpg" alt="抽屜新熱榜"> </div> <div class="new-content"> <div class="part1"> <a href="#" class="show-content" target="_blank"> 普京31日接見俄冰球運動員【環球時報-環球網報道記者趙覺珵】"原諒咱們沒能保護大家免受(興奮劑醜聞的)傷害",俄羅斯總統普京31日對即將前往平昌參加冬奧會的俄羅斯運動員說出了這樣一句使人動容的話。國際奧委會此前以「系統性操縱反興奮劑工 </a> <span class="content-source">-ww4.sinaimg.com</span> <a href="#" class="n2"> <span class="content-kend">42區</span> </a> </div> <div class="part2"> <a href="#" class="recommend" title="推薦"> <span class="hand-icon icon-recommend"></span> <b>4</b> </a> <a href="javascript:" class="discuss"> <span class="hand-icon icon-discuss"></span> <b>5</b> </a> <a href="javascript:" class="collect" title="加入私藏"> <span class="hand-icon icon-collect"></span> <b>私藏</b> </a> <a href="#" class="user-a "> <span> <img src="13.png"> </span> <b>亂太郎</b> <span class="left time-into"> <a class="time-a" href="#" target="_blank"> <b>4分鐘前</b> </a> <i>入熱榜</i> </span> <span class="share-site-to"> <i>分享到</i> <span class="share-icon"> <a class="icon-sina" title="分享到新浪微博" href="#"></a> <a class="icon-douban" title="分享到豆瓣" href="#"></a> <a class="icon-qqzone" title="分享到QQ空間" href="#"></a> <a class="icon-tenxun" title="分享到騰訊" href="#"></a> <a class="icon-renren" title="分享到人人網" href="#"></a> <!--<a class="share-none"></a>--> </span> </span> </a> </div> </div> </div> <div class="item"> <div class="new-pic"> <img src="news.jpg" alt="抽屜新熱榜"> </div> <div class="new-content"> <div class="part1"> <a href="#" class="show-content" target="_blank"> 普京31日接見俄冰球運動員【環球時報-環球網報道記者趙覺珵】"原諒咱們沒能保護大家免受(興奮劑醜聞的)傷害",俄羅斯總統普京31日對即將前往平昌參加冬奧會的俄羅斯運動員說出了這樣一句使人動容的話。國際奧委會此前以「系統性操縱反興奮劑工 </a> <span class="content-source">-ww4.sinaimg.com</span> <a href="#" class="n2"> <span class="content-kend">42區</span> </a> </div> <div class="part2"> <a href="#" class="recommend" title="推薦"> <span class="hand-icon icon-recommend"></span> <b>4</b> </a> <a href="javascript:" class="discuss"> <span class="hand-icon icon-discuss"></span> <b>5</b> </a> <a href="javascript:" class="collect" title="加入私藏"> <span class="hand-icon icon-collect"></span> <b>私藏</b> </a> <a href="#" class="user-a "> <span> <img src="13.png"> </span> <b>亂太郎</b> <span class="left time-into"> <a class="time-a" href="#" target="_blank"> <b>4分鐘前</b> </a> <i>入熱榜</i> </span> <span class="share-site-to"> <i>分享到</i> <span class="share-icon"> <a class="icon-sina" title="分享到新浪微博" href="#"></a> <a class="icon-douban" title="分享到豆瓣" href="#"></a> <a class="icon-qqzone" title="分享到QQ空間" href="#"></a> <a class="icon-tenxun" title="分享到騰訊" href="#"></a> <a class="icon-renren" title="分享到人人網" href="#"></a> <!--<a class="share-none"></a>--> </span> </span> </a> </div> </div> </div> </div> <div id="page-area" class="page-area"> <div id="dig_lcpage"> <ul> <li><span class="ct_pagepw">1</span></li> <li><a href="#" class="ct_pagepa">2</a></li> <li><a href="#" class="ct_pagepa">3</a></li> <li><a href="#" class="ct_pagepa">4</a></li> <li><a href="#" class="ct_pagepa">5</a></li> <li><a href="#" class="ct_pagepa">6</a></li> <li><a href="#" class="ct_pagepa">7</a></li> <li><a href="#" class="ct_pagepa">8</a></li> <li><a href="#" class="ct_pagepa">9</a></li> <li><a href="#" class="ct_pagepa">10</a></li> <li><a href="#" class="ct_page_edge">下一頁</a></li> </ul> </div> </div> </div> <div class="footer-box"> <div class="foot-nav"> <a href="#" target="_blank">關於咱們</a> <span>|</span> <a href="#" target="_blank">聯繫咱們</a> <span>|</span> <a href="#" target="_blank">服務條款</a> <span>|</span> <a href="#" target="_blank">隱私政策</a> <span>|</span> <a href="#" target="_blank">抽屜新熱榜工具</a> <span>|</span> <a href="#" target="_blank">下載客戶端</a> <span>|</span> <a href="#" target="_blank">意見與反饋</a> <span>|</span> <a href="#" target="_blank">友情連接</a> <span>|</span> <a href="#" target="_blank">公告</a> <span>|</span> </div> <div class="foot-nav2"> <a target="_blank" href="#"> <img class="foot_e" src="footer1.gif" width="36" height="14"> </a> <span class="foot_d">旗下站點</span> <span class="food_a">@2018chouti.com</span> <a target="_blank" href="#" class="foot_b">京ICP備09053974號-3 京公安網備 110102145</a> <div style="margin-top: 6px;">版權全部:北京科技有限公司</div> </div> </div> </div> </div> </div> </head> <body> </body> </html>
*{ margin: 0; padding: 0; } body,button,input,select,td,textarea{ font: 12px Tahoma,Verdana,Arial,Helvetica,"\5b8b\4f53,sans-serif"; color: #333; } a{ text-decoration: none; } body{ font-size: 12px; } .head-box{ background-color: #2459a2; height: 44px; width: 100%; position: fixed; top: 0px; left: 0px; } .head-content{ margin: 0 auto; width :1016px; height: 44px; background-color: #2459a2; line-height: 44px; position: relative; } .logo{ background: url("logo.png") no-repeat 0 0; height: 23px; width: 121px; float: left; margin-top: 11px; /*display: inline-block;*/ } .action-menu{ float: left; margin-left: 20px; } .action-menu a.tb{ color: #c0cddf; margin-left: -8px; padding: 0 13px 0 13px; display: inline-block; } .action-menu a.tb:hover{ color: #fff; background-color: #c0cddf; } .action-menu a.active,.action-menu a.active:hover{ color: #fff; background-color:#204982; } .key-search{ float: right; margin-top: 5px; } .key-search .search-txt,.key-search a.i{ float: left; } .key-search .search-txt{ width: 91px; height: 25px; padding: 2px 2px 2px 5px; } .key-search .ico{ background: url("icon.png") no-repeat 0 -197px; height: 12px; width: 15px; display: inline-block; margin-top: 6px; margin-left: 10px; } .key-search a.i{ height: 32px; width: 30px; background-color: #f4f4f4; display: inline-block; border-left: none; } .action-nav{ position: absolute; right:191px ; } .action-nav a{ color: #fff; padding: 0 20px; display: inline-block; } .action-nav a:hover{ background-color: #c0cddf; } /*------------------------------head end-------------*/ .main-content-box{ background-color: #ededed; width: 100%; padding-top: 44px; } .main-content{ margin: 0 auto; background-color: #fff; overflow: hidden; width: 960px; height: auto!important; min-height: 700px; padding: 6px 28px 60px 28px ; } .content-L{ float: left; width: 630px; } .child-nav,.sort-nav,.publish-btn{ float:left; } .child-nav,.sort-nav{ float: left; padding: 10px; } .publish-btn{ float: right; padding: 10px; } .top-area{ overflow: hidden; border-bottom: 1px solid red; } .child-nav .active{ background: url("tip.png") no-repeat 0 -299px; display: inline-block; width: 60px; height: 26px; text-align: center; color: black; } .child-nav .a{ display: inline-block; width: 60px; height: 26px; line-height: 26px; text-align: center; color: #369; font-weight: 700; margin-top: 30px; } .sort-nav{ margin-left: 144px; margin-top: 10px; } .sort-nav .active{ color: #b4b4b4; } .sort-nav a{ margin-left: 10px; color: darkgreen; } .publish-btn{ display: inline-block; width:80px ; height: 18px; color: #fff; background-color: #84a42b; line-height: 18px; text-align: center; } /*-------------------end top_area------- --------*/ .content-list .item{ border-bottom: 1px solid red; margin-top:10px } .item .new-pic{ float: right; margin-top: 5px; margin-left: 15px; } .part2{ padding-top:6px ; color: #ccc; margin-bottom: 12px; } .hand-icon{ background:url("icon_18_118.png") no-repeat 0 0 ; width: 18px; height: 18px; display: inline-block; vertical-align: -4px; } .icon-recommend{ /*background: url("icon_18_118.png");*/ background-position: 0 -40px; } .icon-discuss{ /*background: url("icon_18_118.png");*/ background-position: 0 -100px; } .icon-collect{ /*background: url("icon_18_118.png");*/ background-position: 0 -140px; } .part2 .user-a span{ vertical-align: -4px; } .part1 .content-kend,.part1 .content-source{ color: #d4d4d4; } .part1 .content-kend{ text-decoration: underline; } .part1 .show-content{ color: #369; font-size: 14px; font-weight: 700; } .part b,.time-into i{ color: #d4d4d4; } .share-icon a{ background: url("share_icon.png"); height: 14px; width: 17px; display: inline-block; vertical-align: center; } .share-site-to .share-icon a.icon-sina{ background-position: 0 -90px; } .share-site-to .share-icon a.icon-douban{ background-position: 0 -105px; } .share-site-to .share-icon a.icon-qqzone{ background-position: 0 -120px; width: 16px; height: 14px; } .share-site-to .share-icon a.icon-tenxun{ background-position: 0 -136px; } .share-site-to .share-icon a.icon-renren{ background-position: 0 -151px; } .share-site-to{ float: right; } .share-icon a:hover{ opacity: 1; } .page-area ul li,.ct_page_edge{ display: inline-block; float: left; color: #369; height: 34px; line-height: 34px; text-align: center; width: 37px; border: 1px solid #e1e1e1; border-radius:20%; margin-left: 3px; } .dig_lcpage{ margin-left: 10px; } .ct_page_edge{ width: 70px; } .page-area ul li:hover,.ct_page_edge:hover{ color: #fff!important; background-color: #204982; } .footer-box .foot-nav{ paddi }
下面這兩個圖,使我本身作出來的效果圖,於2018.1.26作成,先記錄於此,不少不完善的地方,可是我學到了許多東西,由於js尚未學,因此,這個項目我確定會修改,繼續完善。java
這個兩個圖纔是源地,也就是抽屜新熱榜的界面,我本身第一次作的與這個還有一些差距,我知道,上傳到這裏的目的,其一,讓看到的盆友繼續完善,其二,也鞭策一下本身,下次完善的時候,也有個對比。python
作完這個項目的總結:1,必定要一步步的認真思考,認真研究網頁的構架git
2,對於內容,一步步的填充,不能着急,心急吃不了熱豆腐github
3,命名必定要規範,代碼不止是本身看,還要其餘人編程
4,路徑必定不要寫死,要否則修改的空間都沒有bootstrap
1.實現與抽屜新熱榜同樣的佈局 2.容許點贊、評論 3.開發登陸、註冊頁面 4.開發發貼功能
bootstrap框架,完成抽屜新熱榜官網頁面。 導航欄,固定在頂部。 註冊登陸,彈出的模態窗口。 發佈,彈出的模態窗口。 點贊,私藏,評論的追加列表。 回到頂部。
下面這兩個圖,使我本身作出來的效果圖,於2018.11.25作成,記錄於此,這是靜態頁面圖
(下面的js完成的效果圖)
經過rel="search",把你的搜索功能放到瀏覽器的快捷搜索工具上
用firefox打開taobao時,看一下地址欄邊上的快捷搜索時,能夠填加一個「淘寶搜索」,完成後,之後就能夠直接在那裏搜索東西了!
在首頁的head標籤里加上
<link rel="search" type="application/opensearchdescription+xml" href=provider.xml" title="關鍵詞搜索" />
這個是讓網站加入QQ登陸接口,這段代碼可放在<head></head>之間。
申請騰訊接口後,會獲得這樣的代碼,加入接口以後,你的網站上面的註冊登陸功能,別人能夠直接用QQ登陸,省去註冊的麻煩。
隱藏域 input 元素的一個屬性值type =「text」 文本框button 按鈕radio 單選框hidden 隱藏域。
<input type="hidden" name="參數名" value="這裏填你的參數值">
其實hidden只是將輸入框隱藏了,裏面的值能夠默認賦值或經過js賦值。
提交form的時候跟其餘的都是同樣的。
語法:選擇器{樣式:值!important;}
說明:提高指定樣式規則的應用優先權,即!important爲開發者提供了一個增長樣式權重的方法,讓瀏覽器首選執行這個語句。
例以下面語法:
div{ margin-left:20px!important; margin-left:40px; }
若是是在除了IE6的瀏覽器中,這些瀏覽器支持!important
屬性,也就是說他們會默認讓margin-left:20px!important;
這條語句生效,下面的不帶!important
聲明的樣式將不會覆蓋它,換句話說就是他的級別最高,下面的人都不能取代我!
!important
在同一條規則集裏不生效。請看下述代碼:
div { margin-left:20px!important; } div { margin-left:40px; }
在上述代碼中,IE6及如下瀏覽器中div
的margin-left
與其它瀏覽器一致,都爲20px;
!important
在同一條規則集內不生效。
!important
被用於一個簡寫的樣式屬性,那麼這條簡寫的樣式屬性所表明的子屬性都會被做用上
!important
。
!important
必須放在一行樣式的末尾而且要放在該行分號前,不然就沒有效果。
這個是爲了用於瀏覽器地址欄裏顯示的圖片。
這樣寫了後,在瀏覽器的地址欄裏,圖片會顯示成如今給的路徑的這個圖片,不過這個路徑好像不能改,只能是網址根目錄下的chouti.ico文件,不過如今好像不用寫這個,只要根目錄下有這個文件,瀏覽器會自動服務出來並顯示。
z-index屬性設置元素的堆疊順序,擁有更高堆疊順序的元素老是會處於堆疊順序較低的元素的前面
註釋:元素可擁有負的z-index屬性值
註釋:z-index僅能在定位元素上奏效(例如:position:absolute;)
簡單說,當你定義的CSS中有position屬性值爲absolute,relative或者fixed,用z-index而後取值方可生效。
才屬性參數值越大,被層疊在最上面。
<a> 標籤的 target 屬性規定在何處打開連接文檔。
_blank -- 在新窗口中打開連接 _parent -- 在父窗體中打開連接 _self -- 在當前窗體打開連接,此爲默認值 _top -- 在當前窗體打開連接,並替換當前的整個窗體(框架頁) 一個對應的框架頁的名稱 -- 在對應框架頁中打開
設置文本的粗細。
該屬性用於設置顯示元素的文本中所用的字體加粗。數字值 400 至關於 關鍵字 normal,700 等價於 bold。每一個數字值對應的字體加粗必須至少與下一個最小數字同樣細,並且至少與下一個最大數字同樣粗。
值 | 描述 |
---|---|
normal | 默認值。定義標準的字符。 |
bold | 定義粗體字符。 |
bolder | 定義更粗的字符。 |
lighter | 定義更細的字符。 |
|
定義由粗到細的字符。400 等同於 normal,而 700 等同於 bold。 |
inherit | 規定應該從父元素繼承字體的粗細。 |
表示調用js的函數login,可是首先頁面內有定義好的一個login()函數。
百度出現了下面四個緣由:
1.出現這個錯誤,最可能的是引用的各個js的調用順序有誤,從新調整其引 用順序看看可否解決? 2.還有一個緣由就是在你引用js時,路徑出錯,不是你項目中正確的文件路徑。 3.還有一個緣由是你的js中有某些值是不存在的。 4.除了以上這個具體的錯誤,還可能遇到相似的Uncaught ReferenceError: XXXX is not defined錯誤,這類錯誤就要多檢查傳值錯誤,或者某些值不存在。
而我就犯了第二個錯,沒有導入路徑,當導入js的路徑就行了。
<script src="./js/index.js"></script>
定義:
取消事件的默認動做,由於瀏覽器的一些行爲,是代碼不能控制的。
語法:
event.preventDefault()
說明:
該方法將通知Web瀏覽器不要執行與事件關聯的默認動做(若是存在這樣的動做)。例如,若是type的屬性是「submit」,在事件傳播的任意階段能夠調用任意的事件句柄,經過調用該方法,能夠阻止提交表單。注意,若是Event對象的cancelable 屬性是 fasle,那麼就沒有默認動做,或者不能阻止默認動做。不管哪一種狀況,調用該方法都沒有做用。
意思是該元素增長一個類active,同時讓他的兄弟li去掉active類。
display屬性設置元素如何顯示
值 | 描述 |
---|---|
none | 此元素不會被顯示。 |
block | 此元素將顯示爲塊級元素,此元素先後會帶有換行符。 |
inline | 默認。此元素會被顯示爲內聯元素,元素先後沒有換行符。 |
list-item | 此元素會做爲列表顯示。 |
run-in | 此元素會根據上下文做爲塊級元素或內聯元素顯示。 |
compact | 此元素會根據上下文做爲塊級元素或內聯元素顯示。 |
marker | |
table | 此元素會做爲塊級表格來顯示(相似 <table>),表格先後帶有換行符。 |
inline-table | 此元素會做爲內聯表格來顯示(相似 <table>),表格先後沒有換行符。 |
table-row-group | 此元素會做爲一個或多個行的分組來顯示(相似 <tbody>)。 |
table-header-group | 此元素會做爲一個或多個行的分組來顯示(相似 <thead>)。 |
table-footer-group | 此元素會做爲一個或多個行的分組來顯示(相似 <tfoot>)。 |
table-row | 此元素會做爲一個表格行顯示(相似 <tr>)。 |
table-column-group | 此元素會做爲一個或多個列的分組來顯示(相似 <colgroup>)。 |
table-column | 此元素會做爲一個單元格列顯示(相似 <col>) |
table-cell | 此元素會做爲一個表格單元格顯示(相似 <td> 和 <th>) |
table-caption | 此元素會做爲一個表格標題顯示(相似 <caption>) |