use*_*796 5 html css css-float
我有一个100%宽度的容器div,.block里面有2个div,宽度均为50%,显示内联块并向左浮动.在这些div之间是否可以拥有一致的20px排水沟?
我尝试了一种简单的方法,将宽度设置为49%,左边的边距为2%,但理想情况下,如果可能的话,我希望在这两个div之间保持一致的20px排水沟.
jsFiddle演示:http ://jsfiddle.net/D6U3t/
HTML:
<div class="container">
<div class="block"></div>
<div class="block"></div>
</div>
Run Code Online (Sandbox Code Playgroud)
CSS:
.container {
position: absolute;
top: 0; left: 0;
width: 100%; height: 300px;
background-color: silver;
}
.block {
position: relative;
width: 50%; height: 200px;
background-color: red;
display: inline-block;
float: left;
}
Run Code Online (Sandbox Code Playgroud)
任何建议将不胜感激!
| 归档时间: |
|
| 查看次数: |
2287 次 |
| 最近记录: |