之前,我使用的是 <table>
将我的页面布局分成 3 个部分,左侧边栏、右侧边栏和主中心面板。现在,在了解到过度使用/误用的缺点之后<table>
, 我想避免为此目的使用表格 & 我希望为这些 3 div
设置样式它们看起来像 <table>
的 3 列行。
关于我如何实现 3 div
的任何意见s 在同一行,将不胜感激。
目前我所有的三个div
s 以线性方式显示,一个接一个。
最佳答案
也许更简单一些,比如:
HTML:
<div id="main">
<div>content</div>
<div>content</div>
<div>content</div>
</div>
CSS:
#main{
margin: 0 auto 0 auto;
width: 960px; /*just an example*/
}
#main div{
float: left;
width: 320px; /* a third of the main width*/
}
希望对您有所帮助。
关于html - 定位 3 个 div,使它们看起来好像放在 3 列的表格行中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6988491/