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

css样式:
1、盒子阴影 box-shadow : h-shadow v-shadow blur spread color inset;
属性
HTML+CSS实现鼠标经过商品盒子阴影浮动效果_第1张图片
2、文字阴影 text-shadow: h-shadow v-shadow blur color;


<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Documenttitle>
    <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>

HTML+CSS实现鼠标经过商品盒子阴影浮动效果_第2张图片

你可能感兴趣的:(HTML+CSS,html,css,css3)