Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/36.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 当单元格较大时,告诉表列不要变宽?_Html_Css_Html Table - Fatal编程技术网

Html 当单元格较大时,告诉表列不要变宽?

Html 当单元格较大时,告诉表列不要变宽?,html,css,html-table,Html,Css,Html Table,当单元格较大时,如何使表上的列不变宽?这是一个演示空白:nowrap是因为我只需要一行文本溢出:省略号用于我想要的省略号(它不需要)和overflow:hidden以防万一。它完全忽略了我的溢出和省略。演示显示了问题(Firefox27和Chrome) 您可以添加表格布局:固定到元素,以便根据第一行单元格的宽度设置表/列的宽度 表{表布局:固定;} 表格布局属性控制用于布局表格的算法 表格单元格、行和列 fixed使用固定表布局算法 规范中规定: 使用此(快速)算法,表的水平布局不会

当单元格较大时,如何使表上的列不变宽?这是一个演示<代码>空白:nowrap是因为我只需要一行<代码>文本溢出:省略号用于我想要的省略号(它不需要)和
overflow:hidden
以防万一。它完全忽略了我的溢出和省略。演示显示了问题(Firefox27和Chrome)


您可以添加
表格布局:固定
元素,以便根据第一行单元格的宽度设置表/列的宽度

表{表布局:固定;}

表格布局
属性控制用于布局表格的算法 表格单元格、行和列

fixed
使用固定表布局算法

规范中规定:

使用此(快速)算法,表的水平布局不会 不依赖于细胞的内容物;这只取决于时间 表的宽度、列的宽度以及边框或单元格间距

CSS:

使用
单词扭曲:打断单词
.lastname
类中


这是小提琴:

如果我这样做,它就不再是一行了
<table>
    <tbody><tr>
        <th>Firstname</th>
        <th class="lastname">Lastname</th>      
        <th>Points</th>
    </tr>
    <tr>
        <td>Jill</td>
        <td>Smith</td>      
        <td>50</td>
    </tr>
    <tr>
        <td>Eve</td>
        <td class="lastname">I am a jerk I am a jerk I am a jerk I am a jerk I am a jerk I am a jerk I am a jerk I am a jerk</td>       
        <td>94</td>
    </tr>
    <tr>
        <td>John</td>
        <td>Doe</td>        
        <td>80</td>
    </tr>
    <tr>
        <td>Adam</td>
        <td>Johnson</td>        
        <td>67</td>
    </tr>
</tbody></table>
table,th,td
{
border:1px solid black;
}

table { width: 800px }
.lastname { width: 300px; white-space:nowrap; text-overflow:ellipsis; overflow:hidden; color:red;}
table,th,td
{
border:1px solid black;
}

table { width: 800px }
.lastname { word-wrap: break-word; width: 300px;  color:red;}

}