wenhui_j 2016-06-22 07:55 采纳率: 0%
浏览 1908

关于min-width网页内容随窗口大小变化而变化的问题

想要的效果是随窗口大小变化时右侧的内容也变化,里面的小div以1,2,4个元素显示,窗口变化时候为什么中间出来了一个上面3个元素下面一个元素的情况?

 <head>
    <meta charset='utf-8'>
    <meta http-equiv="content-type" content="text/html;">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1, maximum-scale=1">
    <title>first test</title>
    <style>
        .box{
            width: 100%;
            height: 100%;
        }
        .b01{
            width: 20%;
            height: 200px;
            background-color: blue;
            float: left;
        }
        .bigBox{
            width: 75%;
            height: 200px;
            margin-left: 15px;
            background-color:#c0c0c0;
            float: left;
        }
        .sbox {
            width: 22%;
            height: 40px;
            margin: 10px;
            float: left;
        }
        @media screen and (min-width: 0px) {
            .sbox{
                width:95%;
                height: 30px;
            }
        }
        @media screen and (min-width: 768px) {
            .sbox{
                width:95%;
                height:30px;
            }
        }
        @media screen and (min-width: 992px) {
            .sbox{
                width:47%;
                height: 70px;
            }

        }
        @media screen and (min-width: 1200px){
            .sbox{
                width: 23%;
                height: 180px;
            }
        }
    </style>

</head>
<body>
<div class="box">
    <div class="b01"></div>
    <div class="bigBox">
        <div class="sbox" style="background-color: red;"></div>
        <div class="sbox" style="background-color: green;"></div>
        <div class="sbox" style="background-color: blue;"></div>
        <div class="sbox" style="background-color: pink;"></div>
    </div>
</div>
</body>
</html>
  • 写回答

1条回答 默认 最新

  • Go 旅城通票 2016-06-22 08:45
    关注

    bigBox不够空间容下4个sbox那不是掉下去了。。因为你的sbox还有margin的

             @media screen and (min-width: 1200px){
                .sbox{
                    width: 22%;
                    height: 180px;
                }
            }
    
    评论

报告相同问题?

悬赏问题

  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制