为什么一模一样抄下来不显示二级导航呢?

来源:4-2 侧边栏导航跟随案例

freelover19

2018-02-04 10:57

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Nav-bar</title>
<style>
*{
padding: 0;
margin: 0;
}
.page{
width: 100%;
height: 3000px;
background: url("mooc.png") center top no-repeat;
}
.nav{
width:160;
height:auto;
position: fixed;
left:0;
top: 50%;
margin-top:-103px;
font-family: 'Miscrosoft YaHei'
}

.nav-li{
width: 160px;
height: 40px;
border-bottom: 1px solid #fff;
background: #333;
text-align: center;
line-height: 40px;
color: #fff;
font-size: 16px;
}
.tit{
width: 160px;
height: 40px;
}
.nav-li ul{
width: 160px;
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>


写回答 关注

3回答

  • 没有可爱的翅膀
    2018-02-17 17:56:27
    已采纳

    .nav-li{

    height:auto;

    }

    这里要改为auto长度才能显示。

    freelo...

    对,我太粗心了

    2018-02-25 22:18:47

    共 2 条回复 >

  • 开开心心就好
    2018-02-06 17:44:48

    Css最后一行少一个position呀

  • ibb
    2018-02-04 14:16:21

    display:none    1)先设置隐藏


    *****:hover ul{ display:block;}    2)在设置鼠标时显示


    3)看视频别快进


    freelo...

    没有啊,这是我看视频一半时候的代码,就是展示直接出现的那个

    2018-02-05 18:10:23

    共 1 条回复 >

css定位 position

老师带你了解CSS中定位的知识,并运用到实际案例中。

49036 学习 · 95 问题

查看课程

相似问题