gpt4 book ai didi

html - Css 转换不适用于 mozilla

转载 作者:行者123 更新时间:2023-11-28 06:01:14 25 4
gpt4 key购买 nike

我正在使用以下代码构建一个带有 :after css 和内容的过渡,它在 chrome 上运行良好,但在 firefox 26.0 上运行不正常。为什么?

我哪里做错了?我看不懂?帮帮我

<html>
<head>

<style type="text/css">
.teacherheading {
display: inline-block;
font-size:20px;
}

.teacherheading::after{content:'educational';

animation: 8s ease-out 2s pulsate;
animation-iteration-count: infinite;

-webkit-animation: 8s ease-out 2s pulsate;
-webkit-animation-iteration-count: infinite;

-moz-animation: 8s ease-out 2s pulsate;
-moz-animation-iteration-count: infinite;

-o-animation: 8s ease-out 2s pulsate;
-o-animation-iteration-count: infinite;

}


@-keyframes pulsate {
0% {content:'educational';}
25% {content:'testprep';}
50% {content:'tutoring';}
75% {content:'training';}
100% {content:'educational';}
}
@-webkit-keyframes pulsate {
0% {content:'educational';}
25% {content:'testprep';}
50% {content:'tutoring';}
75% {content:'training';}
100% {content:'educational';}
}

@-moz-keyframes pulsate {
0% {content:'educational';}
25% {content:'testprep';}
50% {content:'tutoring';}
75% {content:'training';}
100% {content:'educational';}
}

@-o-keyframes pulsate {
0% {content:'educational';}
25% {content:'testprep';}
50% {content:'tutoring';}
75% {content:'training';}
100% {content:'educational';}
}

</style>

<body>
<div style="font-size:20px">
Start your <div class="teacherheading"></div> institution
</div>
</body>
</html>

最佳答案

content 属性并不意味着可以设置动画。

Chrome 似乎允许这样做(我不知道为什么)但 Firefox 更严格一些。

基本上 FF 会遵循预期的行为,而 Chrome 不会。

Content @ MDN

来自 Chris Coyier CSS-Tricks

In my own testing animating content has only worked in stable desktop Chrome (v46 at time of writing). No support anywhere else. No Safari on desktop or iOS. No Firefox. No IE. Each of these browsers will ignore the animation, showing only the original content in the pseudo element.

It might be a handy trick in some distant future or it might never be supported by anything. Non-standard features are always at least at some risk of being deprecated, so this Chrome support may not last forever.

If you need to change content in a cross-browser friendly way

Use JavaScript.

关于html - Css 转换不适用于 mozilla,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36735869/

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