ul li嵌套布局css该怎么写 200
html代码如下,一个嵌套的ulli结构<nav><ul><li>aaa</li><li>bbb</li><li>ccc</li><li><ul><li>ddd</li>...
html代码如下,一个嵌套的ul li结构
<nav>
<ul>
<li>aaa</li>
<li>bbb</li>
<li>ccc</li>
<li>
<ul>
<li>ddd</li>
<li>eee</li>
<li>fff</li>
</ul>
</li>
</ul>
<nav>
css代码如下:
nav ul
{
list-style-type:none;
}
nav ul li
{
float:left;
}
输出结果:
第一层的li水平分布没有问题
可是第二层的li就开始垂直分布了
这是为什么呢
麻烦高手指点
多谢多谢
另外
nav ul li ul
{
list-style-type:none;
}
nav ul li ul li
{
float:left;
}
这部分也添加上去过
可是也没有用 展开
<nav>
<ul>
<li>aaa</li>
<li>bbb</li>
<li>ccc</li>
<li>
<ul>
<li>ddd</li>
<li>eee</li>
<li>fff</li>
</ul>
</li>
</ul>
<nav>
css代码如下:
nav ul
{
list-style-type:none;
}
nav ul li
{
float:left;
}
输出结果:
第一层的li水平分布没有问题
可是第二层的li就开始垂直分布了
这是为什么呢
麻烦高手指点
多谢多谢
另外
nav ul li ul
{
list-style-type:none;
}
nav ul li ul li
{
float:left;
}
这部分也添加上去过
可是也没有用 展开
展开全部
这里有一个二级菜单,下拉导航条的源代码,希望对你有用
<!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=utf-08" />
<title>dropline-水平三级横向弹出菜单</title>
<style type="text/css">
/* common styling */
.hd3_nav {font-family: arial, sans-serif; width:749px; height:30px; position:relative; margin:0; font-size:11px; margin:0; background:#fff; position:relative;}
.hd3_nav ul {padding:0; margin:0; list-style-type: none;}
.hd3_nav ul li {float:left; border-left:1px solid #eee; width:106px;}
.hd3_nav ul li a, .hd3_nav ul li a:visited {display:block; float:left; width:101px; text-decoration:none; padding:0 0 0 5px; height:30px; line-height:30px; color:#000; background:#c9c9a7 url(../../graphics/drop.gif) bottom right no-repeat;}
.hd3_nav ul li ul {display: none;}
/* specific to non IE browsers */
.hd3_nav ul li:hover a {color:#fff; background:#b3ab79;}
.hd3_nav ul li:hover ul {display:block; position:absolute; width:749px; top:30px; left:0; background:#b3ab79; color:#fff;}
.hd3_nav ul li:hover ul.right_side li {float:right; border:0; border-left:1px solid #eee;}
.hd3_nav ul li:hover ul.left_side li {float:left; border:0; border-left:1px solid #eee;}
.hd3_nav ul li:hover ul li a.hide {background:#bd8d5e url(../../graphics/drop2.gif) bottom right no-repeat; color:#fff;}
.hd3_nav ul li:hover ul li:hover a.hide {background:#b3ab79; color:#fff;}
.hd3_nav ul li:hover ul li ul {display: none;}
.hd3_nav ul li:hover ul li a {display:block; background:##b3ab79; color:#fff;}
.hd3_nav ul li:hover ul li a:hover {background:#dfc184; color:#000;}
.hd3_nav ul li:hover ul li:hover ul {display:block; position:absolute; left:0; top:30px; color:#000; background:#dfc184;}
.hd3_nav ul li:hover ul.right li {float:right;}
.hd3_nav ul li:hover ul li:hover a.hide {background:#dfc184; color:#000;}
</style>
</head>
<body>
<div class="hd3_nav">
<ul>
<li><a class="hide" href="../hd3_nav/index.html">第1个</a>
<ul>
<li><a href="../hd3_nav/zero_dollars.html" title="The zero dollar ads page">zero dollars</a></li>
<li><a href="../hd3_nav/embed.html" title="Wrapping text around images">wrapping text</a></li>
<li><a href="../hd3_nav/form.html" title="Styling forms">styled form</a></li>
<li><a href="../hd3_nav/nodots.html" title="Removing active/focus borders">active focus</a></li>
<li><a href="../hd3_nav/hover_click.html" title="Hover/click with no active/focus borders">HOVER/CLICK</a></li>
<li><a href="../hd3_nav/shadow_boxing.html" title="Multi-position drop shadow">shadow boxing</a></li>
<li><a href="../hd3_nav/old_master.html" title="Image Map for detailed information">image map</a></li>
</ul>
</li>
<li><a class="hide" href="index.html">第2个</a>
<ul>
<li><a href="spies.html" title="a coded list of spies">spies hd3_nav</a></li>
<li><a href="vertical.html" title="a horizontal vertical hd3_nav">vertical hd3_nav</a></li>
<li><a href="expand.html" title="an enlarging unordered list">enlarging list</a></li>
<li><a href="enlarge.html" title="an unordered list with link images">link images</a></li>
<li><a href="cross.html" title="non-rectangular links">non-rectangular</a></li>
<li><a href="jigsaw.html" title="jigsaw links">jigsaw links</a></li>
<li><a href="circles.html" title="circular links">circular links</a></li>
</ul>
</li>
<li><a class="hide" href="../layouts/index.html">第3个</a>
<ul>
<li><a href="../layouts/bodyfix.html" title="Cross browser fixed layout">Fixed 1</a></li>
<li><a href="../layouts/body2.html" title="Cross browser fixed layout">Fixed 2</a></li>
<li><a href="../layouts/body4.html" title="Cross browser fixed layout">Fixed 3</a></li>
<li><a href="../layouts/body5.html" title="Cross browser fixed layout">Fixed 4</a></li>
<li><a href="../layouts/minimum.html" title="A simple minimum width layout">minimum width</a></li>
</ul>
</li>
<li><a class="hide" href="../boxes/index.html">第4个</a>
<ul>
<li><a href="spies.html" title="a coded list of spies">spies hd3_nav</a></li>
<li><a href="vertical.html" title="a horizontal vertical hd3_nav">vertical hd3_nav</a></li>
<li><a href="expand.html" title="an enlarging unordered list">enlarging list</a></li>
<li><a href="enlarge.html" title="an unordered list with link images">link images</a></li>
<li><a href="cross.html" title="non-rectangular links">non-rectangular</a></li>
<li><a href="jigsaw.html" title="jigsaw links">jigsaw links</a></li>
<li><a href="circles.html" title="circular links">circular links</a></li>
</ul>
</li>
<li><a class="hide" href="../mozilla/index.html">第5个</a>
<ul>
<li><a href="../mozilla/dropdown.html" title="A drop down hd3_nav">drop down hd3_nav</a></li>
<li><a href="../mozilla/cascade.html" title="A cascading hd3_nav">cascading hd3_nav</a></li>
<li><a href="../mozilla/content.html" title="Using content:">content:</a></li>
<li><a href="../mozilla/moxbox.html" title=":hover applied to a div">mozzie box</a></li>
<li><a href="../mozilla/rainbow.html" title="I can build a rainbow">rainbow box</a></li>
<li><a href="../mozilla/snooker.html" title="Snooker cue">snooker cue</a></li>
<li><a href="../mozilla/target.html" title="Target Practise">target practise</a></li>
</ul>
</li>
<li><a class="hide" href="../ie/index.html">第6个</a>
<ul class="right_side">
<li><a href="../ie/exampleone.html" title="Example one">example one</a></li>
<li><a href="../ie/weft.html" title="Weft fonts">weft fonts</a></li>
<li><a href="../ie/exampletwo.html" title="Vertical align">vertical align</a></li>
</ul>
</li>
<li><a class="hide" href="../opacity/index.html">第6个</a>
<ul class="right_side">
<li><a href="../opacity/colours.html" title="colour wheel">opaque colours</a></li>
<li><a href="../opacity/picturehd3_nav.html" title="a hd3_nav using opacity">opaque hd3_nav</a></li>
<li><a href="../opacity/png.html" title="partial opacity">partial opacity</a></li>
<li><a href="../opacity/png2.html" title="partial opacity II">partial opacity II</a></li>
<li><a href="../hd3_nav/hover_click.html" title="Hover/click with no active/focus borders">HOVER/CLICK</a></li>
</ul>
</li>
</ul>
</div>
</body>
</html>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询