2009-08-14 12 views
0

私はテーブルに定義されたスタイルを持っています。私は次に.tablestyle th { height:26px }を持っています...継承されたCSSの高さをオーバーライドします。

私は今、テーブルの中で特定の(すべてではない)1つの高さを自動的に決定する必要があります。

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

長いものが第ただし、x> 26px、xの高さが必要ですが、不明...私はheight:autoを言って番目のタグにスタイル属性を配置しようとしましたが、それは名誉にいないようです自動割り当て。私がheight: 200pxをstyle属性に入れた場合、それはうまく動作し、200pxになります。問題は、私は本当にその内容に基づいて決定されるべき高さが必要であるということです...

私はより具体的なスタイルを作ることができ、私は上手です。可能であれば、別のスタイルを作成するのではなく、単に影響を受けるタグだけを飾ることができます。

追加情報:
これは表形式のデータ入力フォーム用であり、tdタグも同様に必要です。

答えて

3

追加しよう!重要なあなたのCSS属性

height: 500px !important; 
0
min-height: 26px; 

の終わりにはIE以外のすべてのために動作します。 IEのために、私は典型的には、いくつかのjQueryを使用します。

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

私が思うに、私は私の前に私のコードを持っていません。

0

私は(<th>かどうか<td>)あなたの経験は、私自身に異なっていることを実現するが、通常のテーブルセルにかかわらずheightまたはoverflowに関連するスタイルルールの、コンテンツを表示するために必要なものは何でも高さを採用します。

doctypeを使用していますか?私は一般的に私のページに<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">を使用し、デモページ(this pageにある)がこれをバックアップしているようです。

マークアップ次が使用しているページ:おそらく

<?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> 

、あなたが<span>でセルの内容をラップし、特定の高さ/幅を強制することを使用することができます。マークアップをいくらか複雑にする役目を果たします。

関連する問題