Is there some CSS that I can add inside a <noscript>
that will prevent animations on a certain element when scripts are disabled?
是否有一些我可以在
In other words, I want to prevent CSS3 animations on a certain class when scripts are disabled.
换句话说,我想在禁用脚本时阻止某个类上的CSS3动画。
3 个解决方案
#1
7
What you can do is set a class when JavaScript is enabled. Make sure all the animations look at that class.
你可以做的是在启用JavaScript时设置一个类。确保所有动画都看到该类。
#2
0
With JS you can add a class to your body tag, something like .js-enabled; in your css scope the animations with that specific class.
使用JS,您可以在body标签中添加一个类,例如.js-enabled;在你的css范围内,该特定类的动画。
#3
0
I've had a similar problem recently. The easiest way is to assign a class on load. That is your initial state then, and the state you want something to transition to is either the state without the class (when, for example, you want to reveal stuff) or yet another class. Or, if you're using a looped animation, then of course you don't have to worry about that and just assign animations to a class.
我最近遇到过类似的问题。最简单的方法是在加载时分配一个类。那是你的初始状态,你希望转换到的状态是没有类的状态(例如,当你想要揭示东西时)或另一个类。或者,如果您正在使用循环动画,那么您当然不必担心这一点,只需将动画分配给一个类。
#1
7
What you can do is set a class when JavaScript is enabled. Make sure all the animations look at that class.
你可以做的是在启用JavaScript时设置一个类。确保所有动画都看到该类。
#2
0
With JS you can add a class to your body tag, something like .js-enabled; in your css scope the animations with that specific class.
使用JS,您可以在body标签中添加一个类,例如.js-enabled;在你的css范围内,该特定类的动画。
#3
0
I've had a similar problem recently. The easiest way is to assign a class on load. That is your initial state then, and the state you want something to transition to is either the state without the class (when, for example, you want to reveal stuff) or yet another class. Or, if you're using a looped animation, then of course you don't have to worry about that and just assign animations to a class.
我最近遇到过类似的问题。最简单的方法是在加载时分配一个类。那是你的初始状态,你希望转换到的状态是没有类的状态(例如,当你想要揭示东西时)或另一个类。或者,如果您正在使用循环动画,那么您当然不必担心这一点,只需将动画分配给一个类。