CSS如何实现大型下拉菜单
这篇文章将为大家详细讲解有关CSS如何实现大型下拉菜单,小编觉得挺实用的,因此分享给大家做个参考,希望大家阅读完这篇文章后可以有所收获。

十余年的百色网站建设经验,针对设计、前端、开发、售后、文案、推广等六对一服务,响应快,48小时及时工作处理。全网整合营销推广的优势是能够根据用户设备显示端的尺寸不同,自动调整百色建站的显示方式,使网站能够适用不同显示终端,在浏览器中调整网站的宽度,无论在任何一种浏览器上浏览网站,都能展现优雅布局与设计,从而大程度地提升浏览体验。创新互联从事“百色网站设计”,“百色网站推广”以来,每个客户项目都认真落实执行。
这是一款纯CSS实现的大型下拉菜单。该大型菜单使用HTML和纯CSS代码制作,没有任何js代码,不依赖任意第三方插件。适合用于栏目分类较多的大型网站使用。
HTML结构
该大型菜单的HTML结构如下:
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如何实现大型下拉菜单就分享到这里了,希望以上内容可以对大家有一定的帮助,可以学到更多知识。如果觉得文章不错,可以把它分享出去让更多的人看到。
文章名称:CSS如何实现大型下拉菜单
分享网址:http://www.jxjierui.cn/article/jiojss.html


咨询
建站咨询
