码迷,mamicode.com
首页 > 其他好文 > 详细

响应式flex+calc

时间:2020-12-30 11:25:35      阅读:0      评论:0      收藏:0      [点我收藏+]

标签:软件   jpg   pcb   column   http   www   media   direct   pre   

<!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>

  

响应式flex+calc

标签:软件   jpg   pcb   column   http   www   media   direct   pre   

原文地址:https://www.cnblogs.com/xiaorain124/p/14189674.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!