[英]Fixed table cell size and display length of content with respect to width
我想使用 HTML 和 CSS 制作一个表格。 但问题是表格单元格的内容正在改变它的宽度和高度。 我只想显示适合单元格的起始内容。
我得到什么:
| | | This is some random sentence |
| Column 1 | Column 2 | I have typed here just to |
| | | demonstrate you. |
我想要的是:
| Column 1 | Column 2 | This is some random sente... |
是否可以使用内置的 html/CSS 功能来做到这一点? 如果没有,还有什么方法可以做到这一点?
.long-text{ width:160px; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp:1; overflow: hidden; } td{ border:1px solid; padding:3px; }
<table> <tr> <td>Column 1</td> <td>Column 2</td> <td class="long-text">This is some random sentence I have typed here just to demonstrate to you.</td> <tr> </table>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.