HTML水平导航栏伸缩效果

前端知识

感觉自己前端不是很好,还要多多练习。做了一下笔记。

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>水平导航栏伸缩动画效果</title>
    <script src="../js/jquery.min.js"></script>
    <style>
        *{
            margin: 0px;
            padding: 0px;
            font-size: 14px;
        }
        ul{
            list-style: none; /*无序号*/
            height: 50px;
            padding-left: 30px;
            border-bottom: 5px solid  #f60; /*整个 ul 的底部变宽,为一条线*/

        }
        li{
            float: left;
            margin-top: 20px;
        }
        a{text-decoration: none;/* a 标签的下划线*/
            display: block;/*将 a 标签变成一个块,进而可以设置属性*/
            height: 30px;
            line-height: 30px;  /*文字居中*/
            width: 120px;
            background-color: #ccc;
            margin-bottom: 1px;
            text-align: center;

        }
        a:hover{
            color: #fff;
            background-color: #f60;
            height: 30px;
            line-height: 30px;

        }
    </style>
    <script>
        $(function () {
            $("a").hover(
                function () {
                    $(this).stop().animate({"width":"170px"},200);
                },function () {
                    $(this).stop().animate({"width":"120px"},200);
                }
            )
        });
    </script>
</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>

效果

这里写图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值