gpt4 book ai didi

javascript - 如何为 TD 设置省略号

转载 作者:行者123 更新时间:2023-11-28 17:27:18 25 4
gpt4 key购买 nike

我有以下 JSFiddle:http://jsfiddle.net/nm85L6dr/

HTML:

<div class="module fade">
<span>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.</span>
</div>

<table>
<tr class="module fade">
<td>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.</td>
</tr>
</table>

有什么方法可以为 TD 设置省略号。

最佳答案

您必须将规则移动到 <td>并设置 position: absolute .

body {
padding: 20px;
font: 1.2em/1.2em 'Open Sans', sans-serif;
}
.module {
width: 250px;
margin: 0 0 1em 0;
overflow: hidden;
}
.module span, .module td {
margin: 0;
}

.fade {
position: relative;
height: 3.6em; /* exactly three lines */
}
.fade:after {
content: "";
text-align: right;
position: absolute;
bottom: 0;
right: 0;
width: 70%;
height: 1.2em;
background: linear-gradient(to right, rgba(255, 255, 255, 0), rgba(255, 255, 255, 1) 50%);
}

td.fade {
position: absolute;
}
<div class="module fade">
<span>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.</span>
</div>

<table>
<tr>
<td class="module fade">Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.</td>
</tr>
</table>

关于javascript - 如何为 TD 设置省略号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26919018/

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