码迷,mamicode.com
首页 > 其他好文 > 详细

导航制作

时间:2017-05-20 21:14:20      阅读:219      评论:0      收藏:0      [点我收藏+]

标签:top   log   html   images   pad   20px   text   blog   weight   

首先,来个效果图:!!!!!!!!!!!!!!!!

技术分享

代码如下::

 

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style>
*{
margin: 0;
padding: 0;
}
nav{
width: 100%;
height: 200px;
}
ul{
width: 80%;
height: 100px;
margin: auto;
line-height: 100px;
padding-top: 5%;
}
li{
list-style: none;
width: 20%;
margin-top: 20px;

height: 40px;
float: left;
background: transparent;
border-radius: 10px;
line-height: 40px;
}
li:hover{
background: red;
transition: all ease-in .5s;
box-shadow: 2px 2px 5px grey;
}
a:nth-child(2){
color: black;
display: block;
text-decoration: none;
font-family: "黑体";
font-weight: bold;
}
li:hover a:nth-child(2){
color: white;
}
li>span{
display: block;
}
.icon1,.icon2,.icon3,.icon4,.icon5{
display: block;
margin-left: 30%;
margin-right: 5%;
float: left;
}
.icon1{
margin-top: 10px;
width: 21px;
height: 20px;
background: url("icon.png");
}
.icon1{
margin-top: 10px;
width: 21px;
height: 20px;
background: url("icon.png");
background-position:-22px 0;
}
.icon2{
margin-top: 10px;
width: 20px;
height: 19px;
background: url("icon.png");
background-position:-22px -20px;
}
.icon3{
width: 17px;
height: 23px;
margin-top: 8px;
background: url("icon.png");
background-position:-22px -41px;
}
.icon4{
width: 19px;
height: 16px;
margin-top: 12px;
background: url("icon.png");
background-position:-23px -64px;
}
.icon5{
width: 19px;
height: 16px;
margin-top: 12px;
background: url("icon.png");
background-position:-23px -102px;
}
li:hover span .icon1{
background: url("icon.png");
background-position:0 0;
}
li:hover span .icon2{
background: url("icon.png");
background-position:0 -20px;
}
li:hover span .icon3{
background: url("icon.png");
background-position:0 -41px;
}
li:hover span .icon4{
background: url("icon.png");
background-position:0 -64px;
}
li:hover span .icon5{
background: url("icon.png");
background-position:0 -102px;
}
</style>
</head>
<body>
<nav>
<ul>
<li>
<span>
<a class="icon1" href="#"></a>
<a href="#">热点</a>
</span>
</li>
<li>
<span>
<a class="icon2" href="#"></a>
<a href="#">成都</a>
</span>
</li>
<li>
<span>
<a class="icon3" href="#"></a>
<a href="#">头条</a>
</span>
</li>
<li>
<span>
<a class="icon4" href="#"></a>
<a href="#">教育</a>
</span>
</li>
<li>
<span>
<a class="icon5" href="#"></a>
<a href="#">热点</a>
</span>
</li>
</ul>
</nav>
</body>
</html>


总结:float的包裹性。让你设置后的块级元素失效。
   导航的设置要跟随窗口的变化而变化,不能让
   导航混乱。

 

导航制作

标签:top   log   html   images   pad   20px   text   blog   weight   

原文地址:http://www.cnblogs.com/hm0818/p/6883071.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!