覆盖继承的CSS高度

覆盖继承的CSS高度,css,layout,html-table,Css,Layout,Html Table,我为表格定义了一种样式。然后我有一个.tablestyle th{height:26px} 我现在需要让表中的一个(不是全部)th自动确定其高度 <table class="tablestyle"> <tr><th>Normal Stuff</th></tr> <tr><th>Long Stuff</th></tr> </table> 普通的东西 长的东西 长的东西需要x

我为表格定义了一种样式。然后我有一个
.tablestyle th{height:26px}

我现在需要让表中的一个(不是全部)th自动确定其高度

<table class="tablestyle">
<tr><th>Normal Stuff</th></tr>
<tr><th>Long Stuff</th></tr>
</table>

普通的东西
长的东西
长的东西需要x的高度,其中x>26px,但未知。。。我尝试在th标签上放置一个样式属性,上面写着
height:auto
,但它似乎不支持自动分配。如果我把
height:200px
放在style属性中,它可以正常工作,转到200px。问题是,我真的需要的高度来确定的基础上的内容的th

我意识到我可以做出更具体的风格,我很好。我想如果可能的话,只是装饰受影响的标签,而不是创建一个单独的风格

其他信息:

这是表格数据输入表单,我们同样需要td标签。

尝试添加!在css属性的末尾显示重要信息

height: 500px !important;

尝试添加!在css属性的末尾显示重要信息

height: 500px !important;
将适用于除IE之外的所有内容。对于IE,我通常使用一些jQuery:

if ($('stuff').height() < 26) { $('stuff').height(26); }
if($('stuff').height()<26){$('stuff').height(26);}
我想,我面前没有我的代码

将适用于除IE之外的所有内容。对于IE,我通常使用一些jQuery:

if ($('stuff').height() < 26) { $('stuff').height(26); }
if($('stuff').height()<26){$('stuff').height(26);}

我想,我面前没有我的代码。

我意识到您的体验与我自己的不同,但通常一个表格单元格(无论是
还是
)将采用显示内容所需的任何高度,而不管与
高度
溢出
相关的样式规则

您正在使用doctype吗?我通常在我的页面中使用
,而演示页面(在上)似乎支持这一点

此处的页面使用以下标记:

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<head>
    <title></title>
    <link rel="stylesheet" type="text/css" href="css/stylesheet.css" />

    <style type="text/css" media="all">

table   {width: 80%;
    margin: 1em auto;
    }

    tr,th,td
        {height: 40px;
        }

    th, td  {border: 1px solid #f90;
        }

    </style>

</head>

<body>

<table>

<thead>
<tr><th>Names</th><th>Description</th><th>Actor</th></tr>
</thead>

<tbody>
<tr><td>Number One</td><td>The assumed leader of the Village</td><td>Perhaps Patrick McGoohan</td></tr>
<tr><td>Number Two</td><td>There are two Number Twos with repeat appearances: Leo McKern appeared in three episodes, and Colin Gordon in two. With the exception of "Fall Out", this was the result of the actors performing their roles in two consecutive episodes filmed back to back. Colin Gordon was filmed in "The General" followed immediately with "A. B. and C." McKern was featured in the series' second transmitted episode, "The Chimes of Big Ben," and then featured in the next production episode to be filmed "Once Upon a Time." Three actors who portray Number Twos also appear in other episodes, possibly as different characters — Georgina Cookson ("A. B. and C." as party guest and "Many Happy Returns" as Mrs Butterworth/No. 2), Kenneth Griffith ("The Girl Who Was Death" as Schnipps/No. 2 and "Fall Out" as The Judge) and Patrick Cargill ("Many Happy Returns" as Thorpe, and "Hammer Into Anvil" as No. 2) — although this is ambiguous, particularly in the case of Kenneth Griffith's character.</td><td>Patrick McGoohan</td></tr>
</tbody>

</table>

</body>

</html>

表{宽度:80%;
保证金:1em自动;
}
tr,th,td
{高度:40px;
}
th,td{边界:1px实心#f90;
}
名称描述符
第一,他担任了村里的领袖,也许是帕特里克·麦古汉
第二,有两个重复出现的第二号人物:利奥·麦肯恩出演三集,科林·戈登出演两集。除了“闹翻”之外,这是演员在背靠背连续拍摄的两集中扮演角色的结果。科林·戈登在《将军》中拍摄,紧接着是《A.B.和C》。麦肯恩在该系列的第二集《大本钟的钟声》中担任主角,然后在下一集《曾几何时》中担任主角。三名扮演第二号人物的演员也出现在其他几集中,可能是不同的角色——乔治娜·库克森(“A.B.和C.”作为派对嘉宾和“许多快乐的回报”作为巴特沃斯夫人/第二)、肯尼斯·格里菲斯(“死亡的女孩”作为施尼普斯/第二和“闹翻”作为法官)和帕特里克·卡吉尔(“许多快乐的回报”作为索普,以及“锤进铁砧”作为第二)——尽管这是模棱两可的,尤其是肯尼斯·格里菲斯的角色帕特里克·麦古汉

可以想象,您可以将单元格内容包装在
中,并使用它来强制执行特定的高度/宽度;但它确实会使您的标记变得有些复杂。

我意识到您的体验与我自己的不同,但通常一个表格单元格(无论是
还是
)将采用显示内容所需的任何高度,而不管与
高度
溢出
相关的样式规则

您正在使用doctype吗?我通常在我的页面中使用
,而演示页面(在上)似乎支持这一点

此处的页面使用以下标记:

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<head>
    <title></title>
    <link rel="stylesheet" type="text/css" href="css/stylesheet.css" />

    <style type="text/css" media="all">

table   {width: 80%;
    margin: 1em auto;
    }

    tr,th,td
        {height: 40px;
        }

    th, td  {border: 1px solid #f90;
        }

    </style>

</head>

<body>

<table>

<thead>
<tr><th>Names</th><th>Description</th><th>Actor</th></tr>
</thead>

<tbody>
<tr><td>Number One</td><td>The assumed leader of the Village</td><td>Perhaps Patrick McGoohan</td></tr>
<tr><td>Number Two</td><td>There are two Number Twos with repeat appearances: Leo McKern appeared in three episodes, and Colin Gordon in two. With the exception of "Fall Out", this was the result of the actors performing their roles in two consecutive episodes filmed back to back. Colin Gordon was filmed in "The General" followed immediately with "A. B. and C." McKern was featured in the series' second transmitted episode, "The Chimes of Big Ben," and then featured in the next production episode to be filmed "Once Upon a Time." Three actors who portray Number Twos also appear in other episodes, possibly as different characters — Georgina Cookson ("A. B. and C." as party guest and "Many Happy Returns" as Mrs Butterworth/No. 2), Kenneth Griffith ("The Girl Who Was Death" as Schnipps/No. 2 and "Fall Out" as The Judge) and Patrick Cargill ("Many Happy Returns" as Thorpe, and "Hammer Into Anvil" as No. 2) — although this is ambiguous, particularly in the case of Kenneth Griffith's character.</td><td>Patrick McGoohan</td></tr>
</tbody>

</table>

</body>

</html>

表{宽度:80%;
保证金:1em自动;
}
tr,th,td
{高度:40px;
}
th,td{边界:1px实心#f90;
}
名称描述符
第一,他担任了村里的领袖,也许是帕特里克·麦古汉
第二,有两个重复出现的第二号人物:利奥·麦肯恩出演三集,科林·戈登出演两集。除了“闹翻”之外,这是演员在背靠背连续拍摄的两集中扮演角色的结果。科林·戈登在《将军》中拍摄,紧接着是《A.B.和C》。麦肯恩在该系列的第二集《大本钟的钟声》中担任主角,然后在下一集《曾几何时》中担任主角。三名扮演第二号人物的演员也出现在其他几集中,可能是不同的角色——乔治娜·库克森(“A.B.和C.”作为派对嘉宾和“许多快乐的回报”作为巴特沃斯夫人/第二)、肯尼斯·格里菲斯(“死亡的女孩”作为施尼普斯/第二和“闹翻”作为法官)和帕特里克·卡吉尔(“许多快乐的回报”作为索普,以及“锤进铁砧”作为第二)——尽管这是模棱两可的,尤其是肯尼斯·格里菲斯的角色帕特里克·麦古汉
可以想象,您可以将单元格内容包装在
中,并使用它来强制执行特定的高度/宽度;但它确实会使标记变得有些复杂