gpt4 book ai didi

html - 我在使用 'shimmer' CSS 动画时遇到问题

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

这是我的 fiddle :https://jsfiddle.net/5r19aban/1/

基本上,我希望正方形具有“微光”CSS 效果,但是当我使用标签 span 而不是 div 时,动画会变慢。不过,我真的希望正方形与其旁边的文字对齐。

谁能帮我解决这个问题?我不能使用 div 因为我不想之后换行!

谢谢!

.shimmer{
/* styling stuff */
font-size:36px;
color: rgba(255,255,255,0.1);
}
.shimmer {
/* the shimmer magic */
background: -webkit-gradient(linear,left top,right top,from(#008000),to(#008000),color-stop(.5,#fff));
background: -moz-gradient(linear,left top,right top,from(#008000),to(#008000),color-stop(.5,#fff));
background: gradient(linear,left top,right top,from(#008000),to(#008000),color-stop(.5,#fff));
-webkit-background-size: 25px 100%;
-moz-background-size: 25px 100%;
background-size: 25px 100%;
-webkit-background-clip: text;
-moz-background-clip: text;
background-clip: text;
-webkit-animation-name: shimmer;
-moz-animation-name: shimmer;
-webkit-animation-name: shimmer;
animation-name: shimmer;
-webkit-animation-duration: 1s;
-moz-animation-duration: 1s;
-webkit-animation-duration: 1s;
animation-duration: 1s;
-webkit-animation-iteration-count: infinite;
-moz-animation-iteration-count: infinite;
-webkit-animation-iteration-count: infinite;
animation-iteration-count: infinite;
background-repeat: no-repeat;
background-position: 0 0;
background-color: #006400;
}

@-moz-keyframes shimmer {
0% {
background-position: top left;
}

100% {
background-position: top right;
}
}

@-webkit-keyframes shimmer {
0% {
background-position: top left;
}

100% {
background-position: top right;
}
}

@-o-keyframes shimmer {
0% {
background-position: top left;
}

100% {
background-position: top right;
}
}

@-ms-keyframes shimmer {
0% {
background-position: top left;
}

100% {
background-position: top right;
}
}

@keyframes shimmer {
0% {
background-position: top left;
}

100% {
background-position: top right;
}
}
mark.green {
color:#006400;
font-size:36px;
background: none;
}

mark.yellow {
color:#e6e600;
font-size:36px;
background: none;
}

mark.red {
color:#ff0000;
font-size:36px;
background: none;
}
<span class="shimmer">∎</span> ILS <br>
<span class="shimmer">∎</span> PAC <br>
<span class="shimmer">∎</span> SIP2 <br>
<span class="shimmer">∎</span> Cloud Library <br><br>

最佳答案

您可以使用div,只需将.shimmerdisplay 属性设置为inline-block。您还可以更改 *-animation-duration 以使动画更快或更慢:

.shimmer {
/* styling stuff */
font-size: 36px;
color: rgba(255, 255, 255, 0.1);
display: inline-block;
}
.shimmer {
/* the shimmer magic */
background: -webkit-gradient(linear, left top, right top, from(#008000), to(#008000), color-stop(.5, #fff));
background: -moz-gradient(linear, left top, right top, from(#008000), to(#008000), color-stop(.5, #fff));
background: gradient(linear, left top, right top, from(#008000), to(#008000), color-stop(.5, #fff));
-webkit-background-size: 25px 100%;
-moz-background-size: 25px 100%;
background-size: 25px 100%;
-webkit-background-clip: text;
-moz-background-clip: text;
background-clip: text;
-webkit-animation-name: shimmer;
-moz-animation-name: shimmer;
-webkit-animation-name: shimmer;
animation-name: shimmer;
-webkit-animation-duration: .5s;
-moz-animation-duration: .5s;
-webkit-animation-duration: .5s;
animation-duration: .5s;
-webkit-animation-iteration-count: infinite;
-moz-animation-iteration-count: infinite;
-webkit-animation-iteration-count: infinite;
animation-iteration-count: infinite;
background-repeat: no-repeat;
background-position: 0 0;
background-color: #006400;
}
@-moz-keyframes shimmer {
0% {
background-position: top left;
}
100% {
background-position: top right;
}
}
@-webkit-keyframes shimmer {
0% {
background-position: top left;
}
100% {
background-position: top right;
}
}
@-o-keyframes shimmer {
0% {
background-position: top left;
}
100% {
background-position: top right;
}
}
@-ms-keyframes shimmer {
0% {
background-position: top left;
}
100% {
background-position: top right;
}
}
@keyframes shimmer {
0% {
background-position: top left;
}
100% {
background-position: top right;
}
}
mark.green {
color: #006400;
font-size: 36px;
background: none;
}
mark.yellow {
color: #e6e600;
font-size: 36px;
background: none;
}
mark.red {
color: #ff0000;
font-size: 36px;
background: none;
}
<div class="shimmer">∎</div>ILS
<br>
<div class="shimmer">∎</div>PAC
<br>
<div class="shimmer">∎</div>SIP2
<br>
<div class="shimmer">∎</div>Cloud Library
<br>
<br>

关于html - 我在使用 'shimmer' CSS 动画时遇到问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41025730/

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