gpt4 book ai didi

html - 文本填充颜色 CSS

转载 作者:行者123 更新时间:2023-11-28 04:47:22 24 4
gpt4 key购买 nike

我一直在尝试使用 CSS 从左到右实现文本颜色填充,如下 codepen.io/anon/pen/oYojzZ

然而,不是用颜色填充文本,而是填充背景。在这个例子中,文本颜色黑色应该变成粉红色而不是背景。

非常感谢任何帮助。

谢谢

最佳答案

.tooltiptext {
position: relative;
}
.popUpWord {
color: pink;
}
.popUpWordBlack {
color: black;
}
.outPop {
margin: auto;
background: none;
width: 0;
overflow: hidden;
display: block;
position: absolute;
/* Unset our animation play state initially - this will reset the animation when the hover is no longer */
animation-play-state: unset;
}
/* Since .outPop is hidden we add the style to either when the element is hovered or it's sibling is hovered */
.outPopBlack:hover + .outPop,
.outPop:hover{
/* Turn our animation on when we are hovering over our element */
animation: stripes 2s linear 1 forwards;
}
.outPopBlack {
display: block;
position: absolute;
z-index: -1;
}
@keyframes stripes {
to {
width: 32px;
}
}
<span class="tooltiptext"> 
<span class="outPopBlack">
<span class="popUpWordBlack">hello</span>
</span>
<span class="outPop">
<span class="popUpWord">hello</span>
</span>
</span>

关于html - 文本填充颜色 CSS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40877452/

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