css实现九宫格效果


<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>九宫格</title>
    <style>
        * {margin:0;padding:0;}

        .box {
            width: 600px;
            height: 600px;
            border-top:1px solid red;
            border-left:1px solid red;
            box-sizing: border-box;
            position: relative;
        
        }

        .box .table div {
            box-sizing: border-box;
            display: inline-block;
            width: 196px;
            height:200px;
            border-right: 1px solid red;
            border-bottom:1px solid red;
        }

        .box .d1 {
            box-sizing: border-box;
            position: absolute;
            width: 196px;
            height:200px;
            background-color: orange;
            top:0;
            left:0;
            transition:top 1s,left 1s 1s,opacity 1ms 2s;
        }
        .box:hover .d1 {
            top:200px;
            left:200px;
            opacity: 0;
        }

        .box .d2 {
            box-sizing: border-box;
            position: absolute;
            width: 196px;
            height:200px;
            background-color: orange;
            top:200px;
            left:200px;
            transition: top 1s 2s,left 1s 3s,opacity 1ms 4s,visibility 1s 2s;
            visibility: hidden;
        }
        .box:hover .d2 {
            top:0;
            left:400px;
            opacity:0;
            visibility: visible;
        }

        .box .d3 {
            box-sizing: border-box;
            position: absolute;
            width: 196px;
            height:200px;
            background-color: orange;
            top:0;
            left:400px;
            visibility: hidden;
            transition: top 1s 4s,left 1s 5s,opacity 1ms 6s ,visibility 1s 4s;
        }
        .box:hover .d3 {
            visibility: visible;
            top:408px;
            left:0;
            opacity: 0;
        }

        .box .d4 {
            box-sizing: border-box;
            position: absolute;
            width: 196px;
            height:200px;
            background-color: orange;
            top:408px;
            visibility: hidden;
            transition: top 1s 6s,opacity 1ms 7s,visibility 1s 6s;
        }
        .box:hover .d4 {
            visibility: visible;
            top:0;
            opacity: 0;
        }
    </style>
</head>
<body>
    

    <div class="box">


        <div class="content">
            <div class="d1"></div>
            <div class="d2"></div>
            <div class="d3"></div>
            <div class="d4"></div>
        </div>

        <div class="table">
            <div></div>
            <div></div>
            <div></div>
            <div></div>
            <div></div>
            <div></div>
            <div></div>
            <div></div>
            <div></div>
        </div>


    </div>


</body>
</html>

发布了192 篇原创文章 · 获赞 30 · 访问量 2万+

猜你喜欢

转载自blog.csdn.net/JackieDYH/article/details/104908079
今日推荐