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

导航页面样式

时间:2016-08-07 18:32:52      阅读:148      评论:0      收藏:0      [点我收藏+]

标签:

用一下的代码为例:

<body>

<ul class="nav">
    <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>

1.水平菜单的制作:

*{margin:0; padding:0; font-size:14px;}
ul{ list-style:none;}
a{color:#333;text-decoration:none}
.nav li{ float:left;}
.nav li a{ display:block; text-indent:20px; height:30px; line-height:30px; width:100px; background-color:#efefef; margin-bottom:1px;}
.nav li a:hover{ background-color:#F60; color:#fff}

2.圆角菜单的制作:

 

  *{margin:0; padding:0; font-size:14px;}
        a{color:#333;text-decoration:none}
        .nav{list-style:none; height:30px; border-bottom:10px solid #F60; margin-top:20px; padding-left:50px;}
        .nav li{float:left}
        .nav li a{display:block; height:30px;text-align:center; line-height:30px; width:120px; border-radius:12px 12px 0 0; margin-left:1px;background-color:#ddd;}
        .nav li a.on, .nav li a:hover{background-color:#F60; color:#fff;}

 技术分享

3.高度改变的伸缩导航:

 

*{margin:0; padding:0; font-size:14px;}
a{color:#333;text-decoration:none}
ul{list-style:none; height:50px; border-bottom:5px solid #F60; padding-left:30px;}
ul li{float:left; margin-top:20px;}
a{display:block;height:30px;text-align:center; line-height:30px; width:120px; background-color:#ccc;}
a.on, a:hover{ color:#fff;background-color:#F60;height:40px; line-height:40px;margin-top:-10px;}

 技术分享

4.水平伸缩导航:

* { margin: 0; padding: 0; font-size: 14px; }
a { color: #333; text-decoration: none }
ul { list-style: none; height: 30px; border-bottom: 5px solid #F60; margin-top: 20px; padding-left: 50px; }
ul li { float: left }
ul li a { display: block; height: 30px; text-align: center; line-height: 30px; width:120px; background: #efefef; margin-left: 1px; }
a.on, a:hover { background: #F60; color: #fff; }
<script>
window.onload=function(){
    var aA=document.getElementsByTagName(‘a‘);
    for(var i=0; i<aA.length; i++){
        aA[i].onmouseover=function(){
            var This=this;
            clearInterval (This.time);
            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>

 

导航页面样式

标签:

原文地址:http://www.cnblogs.com/JQ330-54864/p/5746616.html

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