侧边栏导航跟随案例
来源:4-2 侧边栏导航跟随案例
慕雪1434180
2017-10-18 23:14:01
老师,不知道为什么我的代码运行出来无法显示二级栏目,实在找不出哪里出现了问题(还没有设置悬浮出现)。代码如下:
<!DOCTYPE html>
<html>
<head>
<title>position</title>
<meta charset="utf-8">
<style type="text/css">
*{
padding: 0;
margin: 0;
}
.page{
width: 100%;
height: 4043px;
background: url("mooc.png") center top no-repeat;
}
.nav{
width: 160px;
height: auto;
position: fixed;
left: 0;
top: 50%;
margin-top: -103px;
font-family: "Microsoft Yahei";
}
.nav-li{
width: 160px;
height: 40px;
text-align: center;
line-height: 40px;
border-bottom: 1px #fff solid;
background: #333;
color: #fff;
font-size: 16px;
}
.tit{
width: 160px;
height: 40px;
}
.nav-li ul{
width: 100%;
height: auto;
background: #fff;
}
.nav-li ul li{
width: 160px;
height: 40px;
border-bottom: 1px dashed #666;
color:#333;
text-align: center;
line-height: 40px;
}
</style>
</head>
<body>
<div class="page">
<div class="nav">
<div class="nav-li">
<div class="tit">慕课网标题</div>
<ul>
<li>
二级栏目
</li>
</ul>
</div>
<div class="nav-li">慕课网标题</div>
<div class="nav-li">慕课网标题</div>
<div class="nav-li">慕课网标题</div>
<div class="nav-li">慕课网标题</div>
</div>
</div>
</body>
</html>
1回答
怎么都被占用了呢
2017-10-19
因为每一条标题的总容器只有40px高,而一级标题的高度就占了40px,ul就没有空间展示了。将每个标题的总容器高度设为auto或直接不设即可
相似问题