欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

纯CSS实现下拉导航菜单代码

程序员文章站 2022-04-18 23:16:10
...

纯css实现,鼠标划过显示二级菜单。二级菜单自上至下滑入。
纯CSS实现下拉导航菜单代码

<!doctype html>
<html class="no-js" lang="en">
<head>
<meta charset="utf-8">
<title>纯CSS3-红色下拉导航菜单代码</title>
<style>
/*导航栏*/
.nav_menu3,.nav_menu3 ul,.nav_menu3 ul li,.nav_menu3 ul li a,.nav_menu3 #menu-button {margin: 0;padding: 0;border: 0;list-style: none;line-height: 1;display: block;position: relative;-webkit-box-sizing: border-box;-moz-box-sizing: border-box;box-sizing: border-box;}
.nav_menu3 #menu-button {   margin-top: 100px;  background: #F00;  position: absolute;  z-index: 99999;}
.nav_menu3:after,.nav_menu3 > ul:after {content: ".";display: block;clear: both;visibility: hidden;line-height: 0;height: 0;}
.nav_menu3 #menu-button {display: none;}
.nav_menu3 {width: auto;line-height: 1;background: #ffffff;background: #990B2C;}
#menu-line {position: absolute;top: 0;left: 0;height: 3px;background: #990B2C;-webkit-transition: all 0.25s ease-out;-moz-transition: all 0.25s ease-out;-ms-transition: all 0.25s ease-out;-o-transition: all 0.25s ease-out;transition: all 0.25s ease-out;}
.nav_menu3 > ul > li {float: left;}
.nav_menu3.align-center > ul {font-size: 0;text-align: center;}
.nav_menu3.align-center > ul > li {display: inline-block;float: none;}
.nav_menu3.align-center ul ul {text-align: left;}
.nav_menu3.align-right > ul > li {float: right;}
.nav_menu3.align-right ul ul {text-align: right;}
.nav_menu3 > ul > li > a {padding: 30px 10px 29px 10px;text-decoration: none;text-transform: uppercase;color: #eee;-webkit-transition: color .2s ease;-moz-transition: color .2s ease;-ms-transition: color .2s ease;-o-transition: color .2s ease;transition: color .2s ease;border-right:1px solid #990B2C;}
.nav_menu3 > ul > li:hover > a {color: #990B2C;background: #FFF;}
.nav_menu3 > ul > li.nav-has-sub > a {padding-right: 25px;}
.nav_menu3 > ul > li.nav-has-sub > a::after {position: absolute;top: 35px;right: 10px;width: 4px;height: 4px;border-bottom: 1px solid #990B2C;border-right: 1px solid #990B2C;content: "";-webkit-transform: rotate(45deg);-moz-transform: rotate(45deg);-ms-transform: rotate(45deg);-o-transform: rotate(45deg);transform: rotate(45deg);-webkit-transition: border-color 0.2s ease;-moz-transition: border-color 0.2s ease;-ms-transition: border-color 0.2s ease;-o-transition: border-color 0.2s ease;transition: border-color 0.2s ease;}
.nav_menu3 > ul > li.nav-has-sub:hover > a::after {border-color: #990B2C;}
.nav_menu3 ul ul {position: absolute;left: -9999px;}
.nav_menu3 > ul > li > ul {    border-top: 1px solid #FFF;}
.nav_menu3 li:hover > ul {left: auto;}
.nav_menu3.align-right li:hover > ul {right: 0;}
.nav_menu3 ul ul ul {margin-left: 100%;top: 0;}
.nav_menu3.align-right ul ul ul {margin-left: 0;margin-right: 100%;}
.nav_menu3 ul ul li {height: 0;-webkit-transition: height .2s ease;-moz-transition: height .2s ease;-ms-transition: height .2s ease;-o-transition: height .2s ease;transition: height .2s ease;}
.nav_menu3 ul li:hover > ul > li {height: 52px;}
.nav_menu3 ul ul li a {padding: 20px 20px;width: 140px;background: #990B2C;text-decoration: none;color: #eeeeee;-webkit-transition: color .2s ease;-moz-transition: color .2s ease;-ms-transition: color .2s ease;-o-transition: color .2s ease;transition: color .2s ease;border-top: 1px solid #990B2C;}
.nav_menu3 ul ul li:hover > a,.nav_menu3 ul ul li a:hover {color: #990B2C;background: #FFF;border-top: 1px solid #FFF;}
.nav_menu3 ul ul li.nav-has-sub > a::after {position: absolute;top: 25px;right: 10px;width: 4px;height: 4px;border-bottom: 1px solid #eee;border-right: 1px solid #eee;content: "";-webkit-transform: rotate(-45deg);-moz-transform: rotate(-45deg);-ms-transform: rotate(-45deg);-o-transform: rotate(-45deg);transform: rotate(-45deg);-webkit-transition: border-color 0.2s ease;-moz-transition: border-color 0.2s ease;-ms-transition: border-color 0.2s ease;-o-transition: border-color 0.2s ease;transition: border-color 0.2s ease;}
.nav_menu3.align-right ul ul li.nav-has-sub > a::after {right: auto;left: 10px;border-bottom: 0;border-right: 0;border-top: 1px solid #dddddd;border-left: 1px solid #dddddd;}
.nav_menu3 ul ul li.nav-has-sub:hover > a::after {border-color: #990B2C;}
</style>
</head>
<body> 

<div class="nav_menu3">
	<ul>
		<li class='nav-has-sub'><a href='index.html'>庄严禅院</a>
			<ul>
				<li><a href='#'>缘起</a></li>
				<li><a href='#'>寺院建设过程</a></li>
				<li><a href='#'>远景</a></li>
				<li><a href='#'>功德榜芳名</a></li>
				<li><a href='#'>出入账明细表</a></li>
			</ul>
		</li>
		<li class='nav-has-sub'><a href='#'>智觉流通</a>
		  <ul>
			<li><a href='#'>各类经书</a></li>
			<li><a href='#'>戒律</a></li>
			<li><a href='#'>藏</a></li>
			 <li class='nav-has-sub'><a href='#'>论</a>
				<ul>
				   <li><a href='#'>问答</a></li>
				   <li><a href='#'>解惑</a></li>
				</ul>
			 </li>
		  </ul>
	   </li>
	   <li class='nav-has-sub'><a href='#'>中国传统文化</a>
			<ul>
				<li><a href='#'>中医</a></li>
				<li><a href='#'>礼仪</a></li>
				<li><a href='#'>黄帝内经</a></li>
				<li><a href='#'>咨询</a></li>
				<li><a href='#'>免费养老</a></li>
			</ul>
		</li>
	   <li class='nav-has-sub'><a href='#'>世界历学</a>
			<ul>
				<li><a href='#'>世界各地文化</a></li>
			</ul>
		</li>
	   <li class='nav-has-sub'><a href='#'>人类交流</a>
			<ul>
				<li><a href='#'>企业管理</a></li>
				<li><a href='#'>商业模式咨询</a></li>
				<li><a href='#'>科技咨询</a></li>
			</ul>
		</li>
		<li class='nav-has-sub'><a href='#'>游戏人间</a>
		  <ul>
			<li><a href='#'>佛教电影/电视</a></li>
			 <li class='nav-has-sub'><a href='#'>游戏</a>
				<ul>
				   <li><a href='#'>共建极乐</a></li>
				   <li><a href='#'>各种游戏</a></li>
				   <li><a href='#'>猜迷语/猜字</a></li>
				</ul>
			 </li>
		  </ul>
	   </li>
	   <li class='nav-has-sub'><a href='#'>人间杂会</a>
			<ul>
				<li><a href='#'>八卦</a></li>
				<li><a href='#'>新闻</a></li>
				<li><a href='#'>社会</a></li>
				<li><a href='#'>易经</a></li>
				<li><a href='#'>小说/故事</a></li>
			</ul>
		</li>
	   <li class='nav-has-sub'><a href='#'>智力学习</a>
			<ul>
				<li><a href='#'>小学</a></li>
				<li><a href='#'>初中</a></li>
				<li><a href='#'>高中</a></li>
			</ul>
		</li>
	</ul>
</div>

<div style="text-align:center;margin:50px 0; font:normal 14px/24px 'MicroSoft YaHei';">
<p>适用浏览器:360、FireFox、Chrome、Safari、Opera、傲游、搜狗、世界之窗. 不支持IE8及以下浏览器。</p>

</div>
</body>
</html>
相关标签: 导航