英文:
Trying to animate a hyperlink using CSS
问题
我正在尝试将动画animation
应用于包含在.about_us_right
的wpb_wrapper
div内第3个<h4>
中的超链接。
.about_us_list_right .wpb_wrapper h4:nth-child(3) a {
-webkit-animation: animation 3s ease-out !important;
-webkit-animation-iteration-count: infinite !important;
}
@-webkit-keyframes animation {
0% {
color: red !important;
}
50% {
color: green !important;
}
100% {
color: red !important;
}
}
有人能看出这里有什么问题吗?我不能将动画应用于超链接吗?
我以前将这些代码行应用于不同的div,但从未应用于超链接!
英文:
I'm trying to apply the animation animation
to the hyperlink contained in the 3rd <h4>
of a div wpb_wrapper
of .about_us_right
.
.about_us_list_right .wpb_wrapper h4:nth-child(3) a {
-webkit-animation: animation 3s ease-out !important;
-webkit-animation-iteration-count: infinite !important;
}
@-webkit-keyframes animation {
0% {
color: red !important;
}
50% {
color: green !important;
}
100% {
color: red !important;
}
}
Can anyone see what isn't working here? Am I not allowed to apply animations to hyperlinks?
I've applied these lines of code to different divs but never a hyperlink before!
答案1
得分: 1
以下是翻译好的部分:
"So what isn't working about yours? Is it essentially the same as below?
你的有什么问题?基本上和下面的一样吗?
I removed all the "!important" it was cluttering it up.
我移除了所有的“!important”,它让代码看起来混乱。
The anchor <a>
tag IS actually inside the H4 correct? That's how I did it.
锚点 <a>
标签确实是在 H4 内的,对吗?这是我做的方式。
p.s. I assumed by "div wpb_wrapper of .about_us_right" you meant .web_wrapper
is inside about_us_right
.
附言:我假设你所说的 "div wpb_wrapper of .about_us_right" 是指 .web_wrapper
在 about_us_right
内部。
@-webkit-keyframes animation {
0% {
color: red;
}
50% {
color: green;
}
100% {
color: red;
}
}
.about_us_list_right .wpb_wrapper h4:nth-child(3) a {
-webkit-animation: animation 3s ease-out;
-webkit-animation-iteration-count: infinite;
}
英文:
So what isn't working about yours? Is it essentially the same as below?
I removed all the "!important" it was cluttering it up.
The anchor <a>
tag IS actually inside the H4 correct? That's how I did it.
p.s. I assumed by "div wpb_wrapper of .about_us_right" you meant .web_wrapper
is inside about_us_right
.
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-css -->
@-webkit-keyframes animation {
0% {
color: red;
}
50% {
color: green;
}
100% {
color: red;
}
}
.about_us_list_right .wpb_wrapper h4:nth-child(3) a {
-webkit-animation: animation 3s ease-out;
-webkit-animation-iteration-count: infinite;
}
<!-- language: lang-html -->
<div class="about_us_list_right">
<div class = "wpb_wrapper">
<h4>First H4</h4>
<h4>Second H4</h4>
<h4><a href="the link">Third H4</a></h4>
</div>
</div>
<!-- end snippet -->
答案2
得分: 0
As Bman70 said, you can not use important inside keyframes:
https://developer.mozilla.org/en-US/docs/Web/CSS/@keyframes
Declarations in a keyframe qualified with !important are ignored.
英文:
As Bman70 said, you can not use important inside keyframes:
https://developer.mozilla.org/en-US/docs/Web/CSS/@keyframes
Declarations in a keyframe qualified with !important are ignored.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论