响应式flex+calc

<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>教育——专注IT软件,人才培养</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        .landing-wrap {
            margin: 0 auto;
            max-width: 1488px;
            padding: 0 24px;
        }
        .landing-row{
            display: flex;
            flex-wrap: wrap;
            overflow: hidden;
        }
        
        .landing-row-column{
            width: calc((100% - (24px * 3))/4);
            background: #ccc;
            margin-top: 24px;

            /* 以下样式设置column内部,跟响应式无关 */
            display: flex;
            flex-direction: column;
            justify-content: space-between;
            align-items: center;
            padding: 20px;
            box-sizing: border-box;
            border-radius: 10px;
        }
        .landing-row-column:not(:first-child){
            margin-left: 24px;
        }
        .landing-row-column img{
            max-width:100%;
            display: block;
            margin: 0 auto 16px;
        }
        @media screen and (max-width: 1200px){
            .landing-row-column{
                width: calc((100% - (20px * 2))/3);
                background: #ccc;
            }
            .landing-row-column:not(:first-child){
                margin-left: 20px;
            }
            .landing-row-column:last-child{
                margin-left: 0;
            }
        }
        @media screen and (max-width: 840px){
            .landing-row-column{
                width: calc((100% - 18px)/2);
                background: #ccc;
            }
            .landing-row-column:not(:first-child){
                margin-left: 18px;
            }
            .landing-row-column:nth-child(3){
                margin-left: 0;
            }
        }
        @media screen and (max-width: 600px){
            .landing-row{
                display: block;
            }
            .landing-row-column{
                width: 100%;
                background: #ccc;
            }
            .landing-row-column:not(:first-child){
                margin-left: 0;
            }
            
        }
    </style>
    <script>
    </script>
</head>

<body>
    <div class="landing-wrap">
        <div class="landing-row">
            <div class="landing-row-column">
                <img src="https://www.jixin.pro/wp-content/uploads/2018/05/8266%E4%BA%A7%E5%93%81%E5%B0%BA%E5%AF%B8-810-e1532485460430.jpg" alt="图片1">
                <span>PCB板子</span>
            </div>
            <div class="landing-row-column">
                <img src="https://image.lceda.cn/pullimage/mnU2QEj9NhEKrr9umftlGfeOyCGjhrsbxHLPdnQB.jpeg" alt="图片2">
                <span>PCB板子背面</span>
            </div>
            <div class="landing-row-column">
                <img src="https://www.jixin.pro/wp-content/uploads/2018/05/8266%E4%BA%A7%E5%93%81%E5%B0%BA%E5%AF%B8-810-e1532485460430.jpg" alt="图片1">
                <span>PCB板子</span>
            </div>
            <div class="landing-row-column">
                <img src="https://image.lceda.cn/pullimage/mnU2QEj9NhEKrr9umftlGfeOyCGjhrsbxHLPdnQB.jpeg" alt="图片2">
                <span>PCB板子背面</span>
            </div>
        </div>
    </div>
</body>

</html>

  

posted @ 2020-12-25 16:42  xiaorain124  阅读(206)  评论(0)    收藏  举报