我有下面的例子
<table align="right" border="1" cellpadding="1" cellspacing="1">
<tbody>
<tr>
<td>
test
</td>
<td>
test
</td>
</tr>
<tr>
<td>
test
</td>
<td>
test
</td>
</tr>
</tbody>
</table>
<div style="width: 100%; background-color: red">
test
</div>
如果运行代码,div 将进入 float 表格。该表将需要 float ,因此无法更改。有没有办法阻止其他内容进入 float 元素?
最佳答案
一种解决方案是为表格提供明确的背景颜色。
<table style="background:white; float:right" ...
查看新 JSFiddle .
其他答案都会更改其他属性,例如 div 和表格的相对宽度或位置。
关于html - Div 输入 float 表格内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14277985/