search

Home  >  Q&A  >  body text

用CSS3 box-sizing 属性实现两个并排的容器,如果想让容器中间有间隔该如何实现

"
<style>
.container{
margin: 10px 20px;
height: auto;
overflow: hidden;
}
.box{
box-sizing:border-box;
-moz-box-sizing:border-box; /* Firefox /
-webkit-box-sizing:border-box; /
Safari */
width:50%;
float: left;
height: 80px;
margin-bottom: 10px;
background: #fff;
border-top: 5px solid #004389;
text-align: center;
}
</style>

        <p class="container">
            <p class="box">
                <a href="" class="post">产品经理</a>
                <span>广州</span>
                <span class="salary">10k-15k</span>
            </p>
            <p class="box">
                <a href="" class="post">产品经理</a>
                <span>广州</span>
                <span class="salary">10k-15k</span>
            </p>
        </p>

``
想实现两个并排的容器中有一定的间隔,并且浏览器宽度改变时,间隔宽度不变

黄舟黄舟2784 days ago1068

reply all(5)I'll reply

  • 怪我咯

    怪我咯2017-04-17 11:17:02

    Just set the margin value, but the width needs to be adjusted slightly

    reply
    0
  • ringa_lee

    ringa_lee2017-04-17 11:17:02

    。。。。。。。。。。。

    reply
    0
  • 伊谢尔伦

    伊谢尔伦2017-04-17 11:17:02

    margin outer border padding.

    reply
    0
  • 天蓬老师

    天蓬老师2017-04-17 11:17:02

    Easy to set transparent border
    Or just apply another layer and use whatever you want

    reply
    0
  • 迷茫

    迷茫2017-04-17 11:17:02

    If you want to achieve a uniform spacing effect in the overall layout, it is recommended that you use CSS3’s flexible box layout (box-flex)

    reply
    0
  • Cancelreply