2016-08-31 6 views
0

テキストが長すぎる場合は、行の最初の要素を必要とするテーブルをまとめています。そのために私は、このテーブルを持っているだけで、「私は」あなたはthとtdの幅が動作しない

#name{ 
 
    white-space: nowrap; 
 
    overflow: hidden; 
 
    text-overflow: ellipsis; 
 
    width: 100%; 
 
}
<table style="width:100%"> 
 
    <thead> 
 
    <tr> 
 
     <th id="name" style="width:20%">Test name test name test name</th> 
 
     <th id="number">547821365</th> 
 
     <th id="address">test #10900</th> 
 
    </tr> 
 
    </thead> 
 
</table>

は、しかし、これは動作しません非常に長くなければならない略語のテキストを使用することができますしたい

#name{ 
    white-space: nowrap; 
    overflow: hidden; 
    text-overflow: ellipsis; 
    width: 100%; 
} 

を使用し、常に最初の要素はテキストに応じて拡大され、他の列は中断されます。

+0

あなたは後にしているものを明確にすることはできますか?また、 '

j08691

+0

の引用符が欠落しています。最初の列が小さいので、テキストが内部にあるので短縮できますが@ j08691 – sioesi

+0

このhttps://jsfiddle.net/sdbj758n/? – j08691

答えて

1

あなたの名前のcssクラスにfloat:leftを追加できます。ここにある私のfiddle- https://jsfiddle.net/rahulpandey034/oxxnpuo2/

#name{ 
 
    white-space: nowrap; 
 
    overflow: hidden; 
 
    text-overflow: ellipsis; 
 
    width: 100%; 
 
    float: left; 
 
}
<table style="width:100%"> 
 
    <thead> 
 
    <tr> 
 
     <th id="name" style="width:20%">Test name test name test name</th> 
 
     <th id="number">547821365</th> 
 
     <th id="address">test #10900</th> 
 
    </tr> 
 
    </thead> 
 
</table>

+0

not working :(私のために – sioesi

+0

@ニコ・ヘルナンデス・トーレスはあなたのためにはうまくいきませんか? –

+0

彼の最初の列は小さくありません – sioesi

関連する問題