导航菜单的制作
1.垂直菜单的制作
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style type="text/css">
*{
margin: 0;
padding: 0;
font-size: 14px;
}
ul{
list-style: none;
width: 100px;
}
a{
text-decoration: none;
display: block;
height: 30px;
line-height: 30px;
width: 100px;
background: #ccc;
margin-bottom: 1px;
text-indent: 15px;
}
a:hover{
background: #f60;
color: #fff;
}
</style>
</head>
<body>
<ul>
<li> <a href="#">首 页</a> </li>
<li> <a href="#">新闻快讯</a> </li>
<li> <a href="#">产品展示</a> </li>
<li> <a href="#">售后服务</a> </li>
<li> <a href="#">联系我们</a> </li>
</ul>
</body>
</html>2.水平菜单的制作
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style type="text/css">
*{
margin: 0;
padding: 0;
font-size: 14px;
}
ul{
list-style: none;
}
li{
float: left;
}
a{
text-decoration: none;
display: block;
height: 30px;
line-height: 30px;
width: 100px;
background: #ccc;
margin-bottom: 1px;
text-align: center;
}
a:hover{
background: #f60;
color: #fff;
}
</style>
</head>
<body>
<ul>
<li> <a href="#">首 页</a> </li>
<li> <a href="#">新闻快讯</a> </li>
<li> <a href="#">产品展示</a> </li>
<li> <a href="#">售后服务</a> </li>
<li> <a href="#">联系我们</a> </li>
</ul>
</body>
</html>3.圆角菜单的制作
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style type="text/css">
*{
margin: 0;
padding: 0;
font-size: 14px;
}
ul{
list-style: none;
height: 50px;
border-bottom: 5px solid #F60;
padding-left: 30px;
}
li{
float: left;
margin-top: 20px;
}
a{
text-decoration: none;
display: block;
height: 30px;
line-height: 30px;
width: 120px;
background: #ccc;
margin-bottom: 1px;
text-align: center;
background:url(file:///C:/Users/Administrator/Desktop/btnBg.png);
}
.on,a:hover{
background-position: 0 -30px;
color: #fff;
}
</style>
</head>
<body>
<ul>
<li> <a class="on" href="#">首 页</a> </li>
<li> <a href="#">新闻快讯</a> </li>
<li> <a href="#">产品展示</a> </li>
<li> <a href="#">售后服务</a> </li>
<li> <a href="#">联系我们</a> </li>
</ul>
</body>
</html>附上圆角图片
4.伸缩菜单的制作---改变高度
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style type="text/css">
*{
margin: 0;
padding: 0;
font-size: 14px;
}
ul{
list-style: none;
height: 50px;
border-bottom: 5px solid #F60;
padding-left: 30px;
}
li{
float: left;
margin-top: 20px;
}
a{
text-decoration: none;
display: block;
height: 30px;
line-height: 30px;
width: 120px;
background: #ccc;
margin-bottom: 1px;
text-align: center;
background-color:#ccc;
}
.on,a:hover{
background-color: #F60;
color: #fff;
height: 40px;
margin-top:-10px;
line-height: 40px;
}
</style>
</head>
<body>
<ul>
<li> <a class="on" href="#">首 页</a> </li>
<li> <a href="#">新闻快讯</a> </li>
<li> <a href="#">产品展示</a> </li>
<li> <a href="#">售后服务</a> </li>
<li> <a href="#">联系我们</a> </li>
</ul>
</body>
</html>5.伸缩菜单的制作---水平方向拉伸
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style type="text/css">
*{
margin: 0;
padding: 0;
font-size: 14px;
}
ul{
list-style: none;
height: 50px;
border-bottom: 5px solid #F60;
padding-left: 30px;
}
li{
float: left;
margin-top: 20px;
}
a{
text-decoration: none;
display: block;
height: 30px;
line-height: 30px;
width: 120px;
background: #ccc;
margin-bottom: 1px;
text-align: center;
background-color:#ccc;
}
.on,a:hover{
background-color: #F60;
color: #fff;
height: 30px;
line-height: 30px;
}
</style>
<script type="text/javascript">
window.onload=function(){
var aA=document.getElementsByTagName('a');
for(var i=0;i<aA.length;i++){
aA[i].onmouseover=function(){
clearInterval(this.time);
var This=this;
This.time=setInterval(function(){
This.style.width=This.offsetWidth+8+"px";
if(This.offsetWidth>=160){
clearInterval(This.time);
}
},30)
}
aA[i].onmouseout=function(){
clearInterval(this.time);
var This=this;
This.time=setInterval(function(){
This.style.width=This.offsetWidth-8+"px";
if(This.offsetWidth<=120){
This.style.width="120px";
clearInterval(This.time);
}
},30)
}
}
}
</script>
</head>
<body>
<ul>
<li> <a class="on" href="#">首 页</a> </li>
<li> <a href="#">新闻快讯</a> </li>
<li> <a href="#">产品展示</a> </li>
<li> <a href="#">售后服务</a> </li>
<li> <a href="#">联系我们</a> </li>
</ul>
</body>
</html>
4930



被折叠的 条评论
为什么被折叠?



