所以我真的試圖獨佔使用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