当前位置:编程学习 > JS >>

CSS实现带滚动条的二级竖直菜单

CSS实现带滚动条的二级竖直菜单,绝对值得推荐给大家,效果不错,从整体上来说与普通的二级菜单区别不大,只是在二级菜单项目过多的时候,本菜单就显出了优势,会自动出现滚动条,从页不溢出你的规定区域,而且本菜单符合W3C标准,兼容性非常好。
答案:<!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=gb2312" />
<title>CSS实现带滚动条的二级竖直菜单</title>
</head>
<style type="text/css">
.menu 
{font-family: verdana, arial, sans-serif; width:500px; padding:20px 0 100px 100px; position:relative;z-index:100;}
.menu ul 
{padding:0; margin:0; list-style-type: none; border:0;}
.menu ul li 
{float:left; position:relative; margin-right:1px;}
.menu ul li a, 
.menu ul li a:visited 
{display:block; text-align:left; text-decoration:none; width:150px; height:25px; color:#aaa; background:#fff url(/jscss/demoimg/200906/tab.gif); line-height:24px; font-size:11px; text-indent:10px;}
table {border-collapse:collapse;margin:0; padding:0;}
.menu ul li ul {display:none; text-align:left; position:absolute; top:25px; left:-20px; text-align:left;z-index:100; padding:0 30px 20px 20px; background:url(/jscss/demoimg/200906/tab_bot.gif) 20px 100% no-repeat;}
.menu ul li:hover a, 
.menu ul li a:hover
{color:#fff; border:0;}
.menu ul li:hover ul, 
.menu ul li a:hover ul
{display:block;}
.menu ul li:hover ul li, 
.menu ul li a:hover ul li
{background:#363636; color:#000; width:149px; height:100px;overflow:auto; border-left:1px solid #7a7a7a;}
/*hack the widht for IE5.5 */
* html .menu ul li a:hover ul li {width:150px; w\idth:149px;}
.menu ul li:hover ul li a, 
.menu ul li a:hover ul li a
{float:left; display:block; background:#363636; color:#aaa; width:129px; text-align:left; text-decoration:none; border:0; text-indent:10px;}
.menu ul li:hover ul li a:hover,
.menu ul li a:hover ul li a:hover
{text-decoration:none; color:#fff; background:#222;}
</style>
<!--[if lt IE 7]>
<style type="text/css">
.menu ul li ul {display:block; visibility:hidden;}
.menu ul li a:hover ul {visibility:visible;}
</style>
<![endif]-->
<!--[if IE]>
<style type="text/css">
.menu ul li:hover ul li,
.menu ul li a:hover ul li
{
scrollbar-arrow-color: #aaa;
scrollbar-3dlight-color: #888;
scrollbar-highlight-color: #666;
scrollbar-face-color: #444;
scrollbar-shadow-color: #000;
scrollbar-darkshadow-color: #888;
scrollbar-track-color: #363636;
}
</style>
<![endif]-->
<body>
<div class="menu">
<ul>
<li><a class="hide" href="#">官方站<!--[if IE 7]><!--></a><!--<![endif]-->
<!--[if lte IE 6]><table><tr><td><![endif]-->
<ul>
<li>
<a href="#">最新更新</a>
<a href="#">下载排行</a>
<a href="#">网站留言</a>
<a href="#">Georgia</a>
<a href="#">ASP</a>
<a href="#">PHP</a>
<a href="#">ASP.NET</a>
<a href="#">JQUERY</a>
<a href="#">EXT</a>
<a href="#">MOOTOOLS</a>
</li>
</ul>
<!--[if lte IE 6]></td></tr></table></a><![endif]-->
</li>
<li><a class="hide" href="#">特效代码<!--[if IE 7]><!--></a><!--<![endif]-->
<!--[if lte IE 6]><table><tr><td><![endif]-->
	<ul>
	<li>
<a href="#">菜单导航</a>
<a href="#">层和布局</a>
<a href="#">浏览器</a>
<a href="#">Derbyshire</a>
<a href="#">计算</a>
<a href="#">Durham</a>
<a href="#">表单</a>
<a href="#">Es易做图</a>
<a href="#">按钮</a>
<a href="#">CSS</a>
<a href="#">Kent</a>
<a href="#">JavaScript</a>
<a href="#">图片</a>	
</li>
</ul>
<!--[if lte IE 6]></td></tr></table></a><![endif]-->
</li>
</ul>
</div>
</body>
</html>

上一个:CSS滑动门,兼容性非常好
下一个:四个角都为弧形的纯CSS圆角导航栏

CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,