html – 如何强制表中的所有行具有相同的高度

html – 如何强制表中的所有行具有相同的高度,第1张

概述我正在尝试构建一个html表,但我想强制所有行具有相同的高度(无论单元格中有多少内容).如果一个单元格超出空间,我希望它能够截断文本并隐藏其余部分. 这可能使用CSS等吗? 仅IE CSS: #fixedheight { table-layout: fixed;}#fixedheight td { height: 20px; overflow: hidden; 我正在尝试构建一个HTML表,但我想强制所有行具有相同的高度(无论单元格中有多少内容).如果一个单元格超出空间,我希望它能够截断文本并隐藏其余部分.

这可能使用CSS等吗?

解决方法 仅IE

CSS:

#fixedheight {    table-layout: fixed;}#fixedheight td {    height: 20px;    overflow: hIDden;    wIDth: 25%;}

HTML:

<table ID="fixedheight">    <tbody>        <tr>            <td>content</td>            <td>lots of content that should spend way more time wrapPing down than it should if I were just to have a short bit of stuff,that would be invaded by zombIEs and the such</td>            <td>more content</td>            <td>small content</td>            <td>enough already</td>        </tr>    </tbody></table>

通用解决方案

CSS:

#fixedheight {    table-layout: fixed;}#fixedheight td {    wIDth: 25%;}#fixedheight td div {    height: 20px;    overflow: hIDden;}

HTML:

<table ID="fixedheight">    <tbody>        <tr>            <td>                <div>content</div>            </td>            <td>                <div>lots of content that should spend way more time wrapPing down than it should if I were just to have a short bit of stuff,that would be invaded by zombIEs and the such</div>            </td>            <td>               <div>more content</div>            </td>            <td>               <div>small content</div>            </td>            <td>               <div>enough already</div>            </td>        </tr>    </tbody><table>
总结

以上是内存溢出为你收集整理的html – 如何强制表中的所有行具有相同的高度全部内容,希望文章能够帮你解决html – 如何强制表中的所有行具有相同的高度所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1142395.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-31
下一篇 2022-05-31

发表评论

登录后才能评论

评论列表(0条)

保存