div布局系列 - 两端对齐的方法

方式一:box-sizing:border-box
html代码部分

<div class="content clear-fix">
        <div></div>
        <div></div>
        <div></div>
        <div></div>
        <div></div>
        <div></div>
        <div></div>
        <div></div>
        <div></div>
        <div></div>
    </div>

css样式部分

    <style type="text/css">
        .content{
            width: 1080px;
            min-height: 400px;
            border: 1px solid #ccc;
            margin: 10px auto;
            padding: 6px;
        }
        .clear-fix:after{
            content: '';
            display: block;
            clear: both;
        }
        .content>div{
            width: 200px;
            min-height: 230px;
            border: 1px solid #963;
            float: left;
            margin-right: 20px;
            margin-bottom: 10px;
            box-sizing: border-box;
        }
        .content>div:nth-child(5n){
            margin-right: 0px;
        }
    </style>

猜你喜欢

转载自blog.csdn.net/zhuxufeifei/article/details/81842673