小米官网案例

编辑本播客

  • .children()获取子标签,可以添加过滤
  • .hover()鼠标悬浮时执行的动作,接收两个function,第一个表示鼠标移入,第二个表示鼠标移出。移入相当于mouseenter,移除相当于mouselave
  • .stop()停止当前动画
  • .animate()动画设置
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>小米官网案例</title>
    <script src="js/jquery-3.3.1.js"></script>
    <style type="text/css">
        *{
            padding: 0;
            margin: 0;
        }
        ul{
            list-style: none;
        }
        #content{
            width: 800px;
            border: 1px solid green;
            margin: 30px auto;

        }
        #content:after{
            content: '';
            display: block;
            clear: both;
        }
        #content li{
            width: 190px;
            margin-left: 10px;
            margin-top: 10px;
            height: 250px;
            background-color: #FFE4C4;
            float: left;
            overflow: hidden;
            position: relative;
        }
        #content p{
            position: absolute;
            width: 190px;
            height: 50px;
            overflow: hidden;
            line-height: 50px;
            top: 250px;
            background-color: #A9A9A9;
        }
    </style>
</head>
<body>
    <div id="content">
        <ul>
            <li><p>快讯!俄罗斯申请加入联合国人权理事会</p></li>
            <li><p>快讯!俄罗斯申请加入联合国人权理事会</p></li>
            <li><p>快讯!俄罗斯申请加入联合国人权理事会</p></li>
            <li><p>快讯!俄罗斯申请加入联合国人权理事会</p></li>
            <li><p>快讯!俄罗斯申请加入联合国人权理事会</p></li>
            <li><p>快讯!俄罗斯申请加入联合国人权理事会</p></li>
            <li><p>快讯!俄罗斯申请加入联合国人权理事会</p></li>
            <li><p>快讯!俄罗斯申请加入联合国人权理事会</p></li>
        </ul>
    </div>
</body>
<script type="text/javascript">
    $(function () {
        //.hover()两个参数,第一个表示鼠标移入时回调函数,第二个是移除时的回调函数
        //.mouseenter进入,.mouseleave离开
        $("#content li").hover(function () {
            $(this).children('p').stop(true).animate({top:200},100)
        },function () {
            $(this).children('p').stop(true).animate({top:250},100)
        })
    })
</script>
</html>
View Code

 

转载于:https://www.cnblogs.com/yaya625202/p/9202730.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值