您好,我正在尝试在 div 中创建以下结构,但我只需要一些帮助来开始使用 css。
宽度需要100%
最佳答案
<style type="text/css">
.clear{ clear: both; }
.top{ width: 100%; }
.col{ width: 25%; float: left; }
.col, .top{ text-align: center; }
</style>
<div class="main">
<div class="top clear">Menu</div>
<div class="col">Column1</div>
<div class="col">Column2</div>
<div class="col">Column3</div>
<div class="col">Column4</div>
<div class="clear"></div>
</div>
如果您向列添加边框/填充/边距,这将不起作用,如果您想使用它,请使用绝对宽度值。
关于css - div 列布局,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3599475/