小編給大家分享一下純CSS怎么實現(xiàn)大型下拉菜單,相信大部分人都還不怎么了解,因此分享這篇文章給大家參考一下,希望大家閱讀完這篇文章后大有收獲,下面讓我們一起去了解一下吧!
創(chuàng)新互聯(lián)建站從2013年創(chuàng)立,先為夾江等服務(wù)建站,夾江等地企業(yè),進(jìn)行企業(yè)商務(wù)咨詢服務(wù)。為夾江企業(yè)網(wǎng)站制作PC+手機(jī)+微官網(wǎng)三網(wǎng)同步一站式服務(wù)解決您的所有建站問題。
HTML結(jié)構(gòu)
該大型菜單的HTML結(jié)構(gòu)如下:
<nav> <ul class="container ul-reset"> <li><a href='#'>Home</a></li> <li class='droppable'> <a href='#'>Category One</a> <div class='mega-menu'> <div class="container cf"> <ul class="ul-reset"> <h4>Heading 1</h4> <li><a href='#'>Category One Sublink</a></li> <li><a href='#'>Category One Sublink</a></li> <li><a href='#'>Category One Sublink</a></li> <li><a href='#'>Category One Sublink</a></li> <li><a href='#'>Category One Sublink</a></li> </ul><!-- .ul-reset --> <ul class="ul-reset"> <h4>Heading 2</h4> <li><a href='#'>Category One Sublink</a></li> <li><a href='#'>Category One Sublink</a></li> <li><a href='#'>Category One Sublink</a></li> <li><a href='#'>Category One Sublink</a></li> <li><a href='#'>Category One Sublink</a></li> </ul><!-- .ul-reset --> <ul class="ul-reset"> <h4>Heading 3</h4> <li><a href='#'>Category One Sublink</a></li> <li><a href='#'>Category One Sublink</a></li> <li><a href='#'>Category One Sublink</a></li> <li><a href='#'>Category One Sublink</a></li> <li><a href='#'>Category One Sublink</a></li> </ul><!-- .ul-reset --> <ul class="ul-reset"> <h4>Heading 4</h4> <li><img src="http://placehold.it/205x172"></li> </ul> </div><!-- .container --> </div><!-- .mega-menu --> </li><!-- .droppable --> <li class='droppable'> <a href='#'>Category Two</a> <div class='mega-menu'> <div class="container cf"> <ul class="ul-reset"> <h4>Heading 1</h4> <li><a href='#'>Category Two Sublink</a></li> <li><a href='#'>Category Two Sublink</a></li> <li><a href='#'>Category Two Sublink</a></li> <li><a href='#'>Category Two Sublink</a></li> <li><a href='#'>Category Two Sublink</a></li> </ul><!-- .ul-reset --> <ul class="ul-reset"> <h4>Heading 2</h4> <li><a href='#'>Category Two Sublink</a></li> <li><a href='#'>Category Two Sublink</a></li> <li><a href='#'>Category Two Sublink</a></li> <li><a href='#'>Category Two Sublink</a></li> <li><a href='#'>Category Two Sublink</a></li> </ul><!-- .ul-reset --> <ul class="ul-reset"> <h4>Heading 3</h4> <li><a href='#'>Category Two Sublink</a></li> <li><a href='#'>Category Two Sublink</a></li> <li><a href='#'>Category Two Sublink</a></li> <li><a href='#'>Category Two Sublink</a></li> <li><a href='#'>Category Two Sublink</a></li> </ul><!-- .ul-reset --> <ul class="ul-reset"> <h4>Heading 4</h4> <li><a href='#'>Category Two Sublink</a></li> <li><a href='#'>Category Two Sublink</a></li> <li><a href='#'>Category Two Sublink</a></li> <li><a href='#'>Category Two Sublink</a></li> <li><a href='#'>Category Two Sublink</a></li> </ul><!-- .ul-reset --> </div><!-- .container --> </div><!-- .mega-menu--> </li><!-- .droppable --> <li><a href='#'>Category Three</a></li> <li><a href='#'>Category Four</a></li> <li><a href='#'>Category Five</a></li> <li><a href='#'>Category Six</a></li> </ul><!-- .container .ul-reset --> </nav>
CSS
為該大型菜單添加下面的CSS樣式:
/* #Resets –––––––––––––––––––––––––––––––––––––––––––––––––– */ html {box-sizing: border-box;} *, *:before, *:after {box-sizing: inherit; } /* #Universal and Default Styles –––––––––––––––––––––––––––––––––––––––––––––––––– */ body { background: url(../img/black-wood-small.jpg); color: #ddd; font-family: "Open Sans", sans-serif; font-size: 14px; line-height: 1; margin: 0; padding: 0; text-align: center; } a {text-decoration: none;} h2 { font-size: 40px; font-weight: 700; margin-bottom: 20px; margin-top: 20px; } h3 { font-size: 15px; font-weight: 600; margin-bottom: 30px; margin-top: 10px; } .container { margin: auto; width: 940px; } .ul-reset { padding-left: 0; margin-top: 0; margin-bottom: 0; list-style: none; } /* #Navigation Styles –––––––––––––––––––––––––––––––––––––––––––––––––– */ nav { background: #424242; font-size: 0; position: relative; } nav > ul > li { display: inline-block; font-size: 14px; padding: 0 15px; position: relative; } nav > ul > li:first-child {padding-left: 0;} nav > ul > li:last-child {padding-right: 0;} nav > ul > li > a { color: #fff; display: block; position: relative; padding: 20px 0; border-bottom: 3px solid transparent; } nav > ul > li:hover > a { color: #69aae0; border-bottom: 3px solid #69aae0; } /* #Mega Menu Styles –––––––––––––––––––––––––––––––––––––––––––––––––– */ .mega-menu { background: #f0f0f0; display: none; left: 0; position: absolute; text-align: left; width: 100%; } .mega-menu h4 {color: #444;} .mega-menu ul { float: left; margin-bottom: 20px; margin-right: 40px; width: 205px; } .mega-menu ul:last-child {margin-right: 0;} .mega-menu a { border-bottom: 1px solid #ddd; color: #4ea3d8; display: block; padding: 10px 0; } .mega-menu a:hover {color: #2d6a91;} /* #Droppable Class Styles –––––––––––––––––––––––––––––––––––––––––––––––––– */ .droppable {position: static;} .droppable > a:after { content: "\f107"; font-family: FontAwesome; font-size: 12px; padding-left: 6px; position: relative; top: -1px; } .droppable:hover .mega-menu {display: block;} /* #Browser Clearfix –––––––––––––––––––––––––––––––––––––––––––––––––– */ .cf:before, .cf:after { content: " "; /* 1 */ display: table; /* 2 */ } .cf:after {clear: both;}
以上是“純CSS怎么實現(xiàn)大型下拉菜單”這篇文章的所有內(nèi)容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內(nèi)容對大家有所幫助,如果還想學(xué)習(xí)更多知識,歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道!
本文標(biāo)題:純CSS怎么實現(xiàn)大型下拉菜單
URL鏈接:http://muchs.cn/article32/igessc.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供企業(yè)網(wǎng)站制作、網(wǎng)站建設(shè)、網(wǎng)站策劃、靜態(tài)網(wǎng)站、做網(wǎng)站、微信小程序
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)