在HTML中设置表的高度没有任何效果 [英] Setting the height of a table in HTML has no effect

查看:133
本文介绍了在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>

http://jsfiddle.net/zQNS4/

推荐答案

只需将以下内容添加到css:

just add the following to your css:

html, body{
    height: 100%;
}

另一方面,没有 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向导说: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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆