jQuery效果的淡入淡出的案例

<style>
    * {
        margin: 0;
        padding: 0;
        box-sizing: border-box;
    }
    
    body {
        background-color: black;
    }
    
    .box {
        position: absolute;
        width: 780px;
        height: 520px;
        padding: 5px;
        border: 2px solid white;
        left: 50%;
        top: 50%;
        transform: translate(-50%, -50%);
        /* 弹性盒子 */
        display: flex;
        justify-content: space-between;
        flex-wrap: wrap;
        align-content: space-between;
    }
    
    .box .pic1 {
        width: 250px;
        height: 250px;
    }
    
    img {
        width: 250px;
        height: 250px;
    }
</style>

<body>
    <div class="box">
        <div class="pic1"><img src="img/1.jpg" alt=""></div>
        <div class="pic1"><img src="img/2.jpg" alt=""></div>
        <div class="pic1"><img src="img/3.jpg" alt=""></div>
        <div class="pic1"><img src="img/4.jpg" alt=""></div>
        <div class="pic1"><img src="img/5.jpg" alt=""></div>
        <div class="pic1"><img src="img/6.jpg" alt=""></div>
    </div>
    <script>
        $(function() {
            // hover是鼠标经过和离开的复合事件,第一个function是鼠标经过事件
            // 第二个function是鼠标离开事件.
            $('.box > div').hover(function() {
                $(this).siblings().stop().fadeTo(100, 0.5);
            }, function() {
                $(this).siblings().stop().fadeTo(100, 1)

            })
        })
    </script>
</body>

成果展示,用jQuery写的就是简单,
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值