HTML+CSS实现鼠标经过商品盒子阴影浮动效果

css样式:
1、盒子阴影 box-shadow : h-shadow v-shadow blur spread color inset;
属性
在这里插入图片描述
2、文字阴影 text-shadow: h-shadow v-shadow blur color;

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        body {
            background-color: #f5f5f5;
            padding: 0%;
            margin: 0%;
        }
        .box {
            width: 982px;
            height: 270px;
            margin: 100px auto;
        }
        a {
            text-decoration: none;
        }
        .smallbox {
            width: 235px;
            height: 260px;
            margin-left: 14px;
            margin-top: 10px;
            float: right;
            background-color: #fff;
            /* css3效果过渡 */
            transition: all .2s linear;
        }
        .box .smallbox img {
            height: 160px;
            margin: 0 37.5px 12px; 
        }
        .box .smallbox h4 {
            margin: 0 10px 2px;
            color: #333333;
            font-size: 14px;
            font-weight: 400;
            text-align: center;
        }
        .box .smallbox .conten {
            font-size: 12px;
            color: #b0b0b0;
            text-align: center;
            margin: 0 auto;
        }
        .box .smallbox .price {
            color: #ff6700;
            font-size: 14px;
            text-align: center;
        }
        .smallbox:hover {
            /* 盒子阴影 */
            box-shadow: 4px 20px 40px 5px rgba(0, 0, 0, .1); 
            /* 盒子向上移动效果,改变上外边距 */
            margin-top: 8px;
        }
       .box .aa {
            margin-left: 0;    
        }
    </style>
</head>
<body>
    <div class="box">
        <div class="smallbox">
            <a href="https://www.mi.com/">
                <img src="案例.png" alt="">
                <h4>小米9 至尊版</h4>
                <p class="conten">120x变焦/120w秒充/120Hz屏幕</p>
                <p class="price">2499元起</p>
            </a>
        </div>    
        <div class="smallbox">
            <a href="https://www.mi.com/">
                <img src="案例.png" alt="">
                <h4>小米10 至尊版</h4>
                <p class="conten">120x变焦/120w秒充/120Hz屏幕</p>
                <p class="price">2499元起</p>
            </a>
        </div>    
        <div class="smallbox">
            <a href="https://www.mi.com/">
                <img src="案例.png" alt="">
                <h4>小米10 至尊版</h4>
                <p class="conten">120x变焦/120w秒充/120Hz屏幕</p>
                <p class="price">2499元起</p>
            </a>
        </div>    

        <div class="smallbox aa">
            <a href="https://www.mi.com/">
                <img src="案例.png" alt="">
                <h4>小米10 至尊版</h4>
                <p class="conten">120x变焦/120w秒充/120Hz屏幕</p>
                <p class="price">2499元起</p>
            </a>
        </div>    

    </div>
</body>
</html>

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值