Я столкнулся с подобной проблемой, и я нашел решение. Это не зависит от ширины стола, но это немного сложнее. Он работает в любом браузере, включая IE5.5, IE6 и новее.
<style>
.tablediv {
float:left; /* this is a must otherwise the div will take a full width of our page and this way it wraps only our content (so only the table) */
position:relative; /* we are setting this to start the trickie part */
padding-top:2.7em; /* we have to set the room for our spans, 2.7em is enough for two rows otherwise try to use something else; for one row e.g. 1.7em */
}
.leftspan {
position:absolute; /* seting this to our spans will start our behaviour */
top:0; /* we are setting the position where it will be placed inside the .tablediv */
left:0;
}
.rightspan {
position:absolute;
top:0;
right:0;
}
</style>
<div class="tablediv">
<span class="leftspan">Left text</span>
<span class="rightspan">Right text <br /> with row</span>
<table border="1">
<tr><td colspan="3">Header</td></tr>
<tr><td rowspan="2">Left content</td><td>Content</td><td rowspan="2">Right content</td></tr>
<tr><td>Bottom content</td></tr>
</table>
</div>
<!-- If you don't want to float this on the right side of the table than you must use the clear style -->
<p style="clear:both">
something that continues under our tablediv
</p>
Если по какой-то причине вы не можете использовать float, вы можете использовать альтернативный стиль .tablediv, который я нашел по ошибке. Просто замените float:left; to display:inline-block;
. Это работает во всех современных браузерах, но не в IE7 и ниже.
Теперь вы поняли мою точку зрения, и я уверен, что вы найдете другие решения. Только не забывайте, что .tablediv будет таким же длинным, как и внутренний контент. Таким образом, размещение абзаца в нем приведет к растяжению до большего размера, чем наша таблица.