在 HTML 中设置表格的高度无效 [英] Setting the height of a table in HTML has no effect
本文介绍了在 HTML 中设置表格的高度无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
为什么这个桌子高度不起作用?
Why does this table height not function?
<table border=1 bgcolor="green" width=80% height="30%">
<tr>
<td rowspan="2" >
This is 1st row 1st column
</td>
<td >
2
</td>
</tr>
</table>
推荐答案
只需将以下内容添加到您的 css 中:
just add the following to your css:
html, body{
height: 100%;
}
正如其他人所说,table
没有 height
属性,但无论如何大多数浏览器都会这样做.你可以在jsfiddle上看到结果.
As other said, a table
doesn't have a height
-attriute, but most browsers intrepet that anyway. you can see the result on jsfiddle.
你需要这样做的原因是任何应该有 % 高度的父元素也必须有一个高度(正如 Shadow Wizard 所说:究竟是什么的 30%?" - 父元素必须有一个高度高度).
The reason you need to do this is that the parent element of anything that should have a height in % must have a height too (as Shadow Wizard said: "30% of what exactly?" - the parent has to have a height).
这篇关于在 HTML 中设置表格的高度无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文