CSS中overfloat的小技巧

來源:互聯網
上載者:User
<!DOCTYPE html><html lang="en"><head>    <meta charset="UTF-8">    <title>Document</title>    <style>        /*此方法可以完美的解決最右邊的盒子不需要特別設定margin-right:0的問題;*/        /*要點:1 最外面的盒子設定為自已所需要的寬度              2 裡麵包含所要排列的若干個盒子的塊寬度設定為父盒子寬度加上多餘的margin-right的寬度             3 為父盒子設定overflow:hidden             */        *{            margin:0;            padding:0;        }        .out_wrap{            width:900px;            height:500px;            background:black;            overflow: hidden;            margin:0 auto;        }        .lists{            width:990px;        }        .item{            width:280px;            height:100px;            float:left;            margin-right:50px;            background:red;        }    </style></head><body>    <div class="out_wrap">        <ul class="lists">            <li class="item"></li>            <li class="item"></li>            <li class="item"></li>        </ul>    </div></body></html>
相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.