zoukankan      html  css  js  c++  java
  • 浮动的同级盒子顶对齐

    情景:四个盒子如下图布局,使用浮动,可以看到3和4是顶对齐的

    <body>
        <div class="w">
            <div class="box1">1</div>
            <div class="box2">2</div>
            <div class="box3">3</div>
            <div class="box4">4</div>
        </div>
    </body>
    <style>
            .w{
                width: 1000px;
                margin: 0 auto;
            }
            .box1{
                background: rgb(226, 23, 23);
                height: 200px;
                width: 300px;
                float: left;
            }
            .box2{
                background: #008000;
                height: 100px;
                width: 400px;
                float: left;
            }
            .box3{
                background:#0000ff;
                height: 100px;
                width: 400px;
                float: left;
            }
            .box4{
                background: #000000;
                width: 300px;
                height: 50px;
                float: right;
                color: #ffebcd;
            }
        </style>

    此时会看到出现bug,4盒子上不去,解决方法是把4盒子放到2盒子和3盒子中间

     <div class="w">
            <div class="box1">1</div>
            <div class="box2">2</div>
            <div class="box4">4</div>
            <div class="box3">3</div>
        </div>

  • 相关阅读:
    2-SAT
    模板 两次dfs
    SG函数与SG定理
    NIM博弈
    python 给小孩起名
    pytest 数据驱动
    pytest 结合selenium 运用案例
    字符串的转换方法与分割
    字符串的方法
    字符串常量池与字符串之间的比较
  • 原文地址:https://www.cnblogs.com/EricZLin/p/8745628.html
Copyright © 2011-2022 走看看