HTML:
<br/><br/><br/><br/><br/>
<table>
<tr>
<td class="container">
<button class="del">delete</button>
</td>
</tr>
</table>
<br/><br/><br/><br/><br/>
<div class="container">
<button class="del">delete</button>
</div>
CSS:
.container {
position: relative;
border: 1px solid red;
height: 50px;
width: 200px;
}
.del {
position: absolute;
top: 3px;
right: 3px;
}
为什么div
里面的按钮会放在div的右上角,而td
里面的按钮会放在表格外面?
如何解决?
最佳答案
我觉得跟td
的显示风格有关,就是table-cell
。如果将其设置为 display:block
,它将正常工作。
只需将 display:block
添加到您的 .container 样式即可。
正如 freewind 指出的那样,如果您的浏览器支持 td,最好使用 inline-block
,因为 td 通常显示在一行中。
关于html - 带有 `position: absolute` 的内部按钮将放置在 table 外面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10059841/