我在表格内有一张高度/宽度为 100% 的图像。 我定义了表大小,但在我也定义了 TD 大小之前它不起作用。 如何让 TD 继承表格大小,这样我就不必在 CSS 中重复大小?
最佳答案
.g {
width:40px;
height:40px;
}
img {
height:inherit;
width:inherit;
}
td, tr, tbody {
height:inherit;
width:inherit;
}
<table class="g" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><img src="http://www.google.com/logos/2012/stgeorge12-hp.png"></td>
</tr>
</table>
<div class="g"><img src="http://www.google.com/logos/2012/stgeorge12-hp.png"></div>
关于html - 如何设置 HTML 表格单元格继承其大小?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10508188/