簡體   English   中英

CSS:2列表,如何使一列盡可能小但不換行,而另一列盡可能大?

[英]CSS: 2-column table, how to make one column as small as possible but no wrap and the other as big as possible?

我有兩列表(寬度:100%)。 我希望第一列盡可能小,但文本不應換行。 另一列應盡可能大。

<table style="width:100%">
    <tr>
        <td>Some example text:</td>
        <td><input type=text/></td>
    </tr>
</table>

任何想法?

這樣的事情應該可以解決問題:

td:first-child {
    white-space: nowrap;
}
td:last-child {
    width: 100%;
}

http://jsfiddle.net/m1vtendt/

您需要將兩個CSS規則應用於第一個單元格:

white-space: nowrap;
width: 1%;

第一個防止文本換行,第二個使單元格從1%的寬度擴展到內容的寬度。

演示: http //jsfiddle.net/zm6L8gzu/2/

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM