所以我真的试图独占使用div,而不是使用表格进行布局,但我仍然陷在这里和那里。今天我有其中一种情况。让div的行为像一张桌子
考虑下面的标记:
<div style="width:943px;margin:0px auto;height:auto">
<div style="display:block;clear:both">
<div style="float:left;display:block-inline;clear:none;background:url(tl.png);width:26px;height:25px"></div>
<div style="float:left;display:block-inline;clear:none;background:url(t.png) repeat-x;width:865px;height:25px"></div>
<div style="float:left;display:block-inline;clear:none;background:url(tr.png);width:26px;height:25px"></div>
</div>
<div style="height:auto;display:block;clear:both">
<div style="float:left;width:26px;display:block-inline;clear:none;background:url(l.png) repeat-y;width:26px;height:100%"></div>
<div style="padding:0 15px;height:100%;float:left;width:835px;display:block-inline;background:#FFF;clear:none;">
<br />
Some text heeere.
<br />
Some more text heeere.
</div>
<div style="float:left;width:26px;display:block-inline;clear:none;background:url(r.png) repeat-y;width:26px;height:100%"></div>
</div>
<div style="display:block;clear:both">
<div style="float:left;display:block-inline;clear:none;background:url(bl.png);width:26px;height:25px"></div>
<div style="float:left;display:block-inline;clear:none;background:url(b.png) repeat-x;width:865px;height:25px"></div>
<div style="float:left;display:block-inline;clear:none;background:url(br.png);width:26px;height:25px"></div>
</div>
</div>
现在,这是什么做的它:
alt text http://img97.imageshack.us/img97/4281/screenshot20100215at935.png
注意,它的过去的页面高度略去。
这就是我想做的事情:
alt text http://img714.imageshack.us/img714/8504/screenshot20100215at936.png
我希望它流体“适合”的文字没有我指定的高度。似乎问题在于两侧的div除非将高度指定为100%,否则无法工作。有没有其他的/更简单的方法来做到这一点?
谢谢!
为什么你要divs行为像一张桌子?这不是什么表?使用表格所需的行为是表格的缺点是什么? – Rich 2010-02-15 20:13:54
您可以制作草图来展示它应该是什么样子?很难想象。 – 2010-02-15 20:14:25
@我问自己同样的问题,但这看起来像合法*布局*,而不是表格数据。我已经建议使用一张桌子,清理霰弹枪并准备进行火焰战争:) – 2010-02-15 20:15:00