我想在我的頁面上浮動一對流體div,每個佔用其容器寬度的一半,但在它們之間的邊距爲10px。我這樣做的jsfiddle http://jsfiddle.net/andfinally/sa53B/5/,和這裏的HTML:浮動兩個50%寬度的div與一個10px的邊距
<div class="clearfix">
<a class="prev" href="#">Previous</a>
<a class="next" href="#">Next</a>
</div>
和CSS:
.prev {
background: black;
color: white;
font-size: 16px;
margin-bottom: 10px;
display: block;
float: left;
box-sizing: border-box;
width: 50%;
margin-right: 5px;
}
.next {
background: black;
color: white;
font-size: 16px;
margin-bottom: 10px;
display: block;
float: right;
box-sizing: border-box;
width: 50%;
margin-left: 5px;
}
箱上漿規則是不夠的,使這項工作 - 的div超過50 %寬。在this question的答案之一有人建議使用CSS顯示錶。任何人都可以解釋如何在這種情況下做出這項工作?
謝謝!
是否一定需要10px的?它也可能是一個流動的度量單位嗎?你可以製造兩個集裝箱48%的寬度,然後給出第一個4%的保證金。 – chipcullen 2013-03-01 18:20:38
@chipcullen that would not put space between the two divs – 2013-03-01 18:26:26
@EricLemos - 我認爲它會 - 見http://jsfiddle.net/andfinally/sa53B/5/ – chipcullen 2013-03-01 18:28:41