<div>
<span>left</span>
<span>right</span>
<!-- new line break, so no more content on that line -->
<table>
...
</table>
</div>
我如何定位这些跨度(它们可以更改为任何元素),以便根据表的大小(未在任何地方定义,也不应该定义)将跨度定位在左侧的顶部 table 和 table 的右边。
例子:
a b table0 table1 table2
(其中a是左跨度,b是右跨度)
附言您可以更改除内表 html 之外的任何内容。
最佳答案
<style type="text/css">
#wrapper, #top, #tableArea
{
width: 100%;
padding: 10px;
margin: 0px auto;
}
#top
{
padding: 0px;
}
#leftBox, #rightBox
{
margin: 0px;
float: left;
display: inline;
clear: none;
}
#rightBox
{
float: right;
}
</style>
<div id="wrapper">
<div id="top">
<div id="leftBox">A</div>
<div id="rightBox">b<</div>
</div>
<div id="tableArea">
<table> ... </table>
</div>
</div>
关于html - 如何定位 SPAN 使其与 TABLE 的任一侧和上方对齐?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/228102/