gpt4 book ai didi

HTML 表格边框和文本溢出

转载 作者:太空宇宙 更新时间:2023-11-04 13:18:33 26 4
gpt4 key购买 nike

我正在使用一些 CSS 显示一个 HTML 表格,如下所示。

<style type="text/css">
.style-class {
table-layout: fixed;
width: 20%;
white-space: nowrap;
overflow: hidden;
text-overflow:ellipsis;
border: 1px;
}
</style>

<table rules="all" class="style-class">
<tr>
<td>a</td>
<td>Text overflow ellipsis demo.</td>
</tr>

<tr>
<td>b</td>
<td>Text overflow ellipsis demo.</td>
</tr>
</table>

Mozilla FireFox (29.0.1) 正确显示如下。

enter image description here

Google Chrome (35.0.1916.153 m) 显示它时缺少右边框和底边框,如下面的快照所示。

enter image description here

Internet Explorer (8) 显示此表格时完全没有边框,如下所示。

enter image description here

此表是否可以显示所有边框以及 text-overflow:ellipsis 这对于 FireFox 显示很重要,如在相应的快照中所示?

最佳答案

通过将溢出和边框规则移动到单元格而不是整个表格,您可以获得所需的效果。试试这个 CSS:

.style-class {
table-layout: fixed;
width: 20%;
border-collapse: collapse;
border: 1px solid #000;
}
.style-class td {
border: 1px solid #000;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}

关于HTML 表格边框和文本溢出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24231121/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com