gpt4 book ai didi

html - text-overflow 属性的 fade 值是如何工作的?

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

我需要在每个 flex-child 中有一行描述,为此我想使用这个 fade() 值。但它不起作用。

.flex-container {
display: flex;
flex-wrap: wrap;
justify-content: center;
flex-direction: row;
}

.flex-child {
border: 1px black solid;
width: 40%;
max-height: 3rem;
padding: 10px;
margin: 5px;
overflow: hidden;
}

.flex-child p {
font-weight: bold;
font-size: 1rem;
overflow: hidden;
text-align: justify;
white-space: nowrap;
text-overflow: fade(10%);
}
<div class="flex-container">
<div class="flex-child">
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.
</p>
</div>
<div class="flex-child">
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.
</p>
</div>
</div>

我希望它会褪色,变成透明文本。还是对上面的值有误解?

最佳答案

fade 仅处于“实验阶段”,为not yet supported通过任何浏览器。

相反,您可以向位于文本顶部的 flex-item 添加一个伪元素,并具有背景渐变。

我还添加了 pointer-events: none; 因此您仍然可以选择下面的文本。

要更改渐变的大小,只需更改 .flex-item::afterwidth 值即可。

.flex-container {
display: flex;
flex-wrap: wrap;
justify-content: center;
flex-direction: row;
}

.flex-child {
border: 1px black solid;
width: 40%;
max-height: 3rem;
padding: 10px;
margin: 5px;
overflow: hidden;
position: relative;
}

.flex-child::after {
content: '';
display: block;
position: absolute;
top: 0;
right: 10px; /* match parent padding-right */
height: 100%;
width: 100px;
background-image: linear-gradient(to right, rgba(255,255,255,0), white);
z-index: 2;
pointer-events: none;
}

.flex-child p {
font-weight: bold;
font-size: 1rem;
overflow: hidden;
text-align: justify;
white-space: nowrap;
}
<div class="flex-container">
<div class="flex-child">
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.
</p>
</div>
<div class="flex-child">
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.
</p>
</div>
</div>

关于html - text-overflow 属性的 fade 值是如何工作的?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57189157/

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