尝试使用CSS来实现超链接的动画效果。

huangapple go评论70阅读模式
英文:

Trying to animate a hyperlink using CSS

问题

我正在尝试将动画animation应用于包含在.about_us_rightwpb_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_wrapperabout_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;
}

First H4

Second H4

Third H4

英文:

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 &lt;a&gt; 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 -->

&lt;div class=&quot;about_us_list_right&quot;&gt;

&lt;div class = &quot;wpb_wrapper&quot;&gt;
&lt;h4&gt;First H4&lt;/h4&gt;
&lt;h4&gt;Second H4&lt;/h4&gt;
&lt;h4&gt;&lt;a href=&quot;the link&quot;&gt;Third H4&lt;/a&gt;&lt;/h4&gt;
&lt;/div&gt;

&lt;/div&gt;

<!-- 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.

huangapple
  • 本文由 发表于 2023年6月26日 06:13:52
  • 转载请务必保留本文链接:https://go.coder-hub.com/76552619.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定