亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

固定表單元格寬度

固定表單元格寬度

幕布斯6054654 2019-11-25 13:52:54
許多人仍然使用表格來布局控件,數據等。-流行的jqGrid就是一個例子。但是,發生了一些我似乎無法理解的魔術(它的桌子大聲喊叫,可能會有多少魔術?)如何設置表的列寬并使它像jqGrid那樣遵守?。咳绻覈L試復制此內容,即使我設置了every <td style='width: 20px'>,只要這些單元格之一的內容大于20px,該單元格就會展開!有什么想法或見解嗎?
查看完整描述

3 回答

?
手掌心

TA貢獻1942條經驗 獲得超3個贊

現在在HTML5 / CSS3中,我們為該問題提供了更好的解決方案。我認為建議使用這種純CSS解決方案:


table.fixed {table-layout:fixed; width:90px;}/*Setting the table width is important!*/

table.fixed td {overflow:hidden;}/*Hide text outside the cell.*/

table.fixed td:nth-of-type(1) {width:20px;}/*Setting the width of column 1.*/

table.fixed td:nth-of-type(2) {width:30px;}/*Setting the width of column 2.*/

table.fixed td:nth-of-type(3) {width:40px;}/*Setting the width of column 3.*/

<table class="fixed">

    <tr>

        <td>Veryverylongtext</td>

        <td>Actuallythistextismuchlongeeeeeer</td>

        <td>We should use spaces tooooooooooooo</td>

    </tr>

</table>

您需要width在困擾解決方案中設置表的偶數。否則它將無法正常工作。vsync建議的

另一個CSS3新功能是:。這會將單詞中沒有空格的單詞也分成多行。只需像這樣修改代碼:word-break:break-all;


table.fixed { table-layout:fixed; width:90px; word-break:break-all;}


查看完整回答
反對 回復 2019-11-25
  • 3 回答
  • 0 關注
  • 375 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號