css实现双重背景图,过度动画,缩放等

2020-06-11  本文已影响0人  随风飞2019
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link href="https://lib.baomitu.com/twitter-bootstrap/3.4.1/css/bootstrap.css" rel="stylesheet">
    <title>Document</title>
    <style>
        body{
            margin: 0;
            padding: 0;
        }
        .container{
            box-sizing: border-box;
            font-style: 22px;
            color: #FFF;
        }
        .container .col-md-3,.container .col-md-6{
            height: 170px;
            background-attachment: fixed;
            background-size: cover;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            border: 2px solid #FFF;   
            transition: all 0.4s ease-in-out;
        }
        .container .col-md-3:hover,.container .col-md-6:hover{
            opacity: 0.7;
            transform: scale(0.99);
            font-weight: bold;
            font-size: 24px;
        }
        .bg1{
            background-image: url("./img/01.jpg");
        }
        .bg2{
            background-image: url("./img/02.jpg");
        }
    </style>
</head>

<body>
    <div class="container center-block text-center">
            <div class="col-md-6 bg1">
                <div>16<span>24</span></div>
                <div>完成目标数</div>
            </div>
            <div class="col-md-3 bg2">
                <div><span class="glyphicon glyphicon-film"></span></div>
                <div>呼吸</div>
            </div>
            <div class="col-md-3 bg2">
                <div><span class="glyphicon glyphicon-random"></span></div>
                <div>呼吸</div>
            </div>


            <div class="col-md-3 bg2">
                <div>16<span>24</span></div>
                <div>完成目标数</div>
            </div>
            <div class="col-md-3 bg2">
                <div><span class="glyphicon glyphicon-film"></span></div>
                <div>呼吸</div>
            </div>
            <div class="col-md-6 bg1">
                <div><span class="glyphicon glyphicon-random"></span></div>
                <div>呼吸</div>
            </div>

            <div class="col-md-6 bg1">
                <div>16<span>24</span></div>
                <div>完成目标数</div>
            </div>
            <div class="col-md-3 bg2">
                <div><span class="glyphicon glyphicon-film"></span></div>
                <div>呼吸</div>
            </div>
            <div class="col-md-3 bg2">
                <div><span class="glyphicon glyphicon-random"></span></div>
                <div>呼吸</div>
            </div>

            <div class="col-md-3 bg2">
                <div>16<span>24</span></div>
                <div>完成目标数</div>
            </div>
            <div class="col-md-3 bg2">
                <div><span class="glyphicon glyphicon-film"></span></div>
                <div>呼吸</div>
            </div>
            <div class="col-md-6 bg1">
                <div><span class="glyphicon glyphicon-random"></span></div>
                <div>呼吸</div>
            </div>
    </div>
</body>
</html>

background-attachment: fixed;
background-size: cover;
实现背景图平铺展开,各自显示各自区域的背景图

上面transition: all 0.4s ease-in-out;
下面opacity: 0.7;transform: scale(0.99);
实现动画效果过度,缩放

上一篇下一篇

猜你喜欢

热点阅读