我一直在尝试使用内联样式方法在 CSS 中添加动画,但它不起作用
我尝试使用内联样式在 CSS 中添加动画,但它没有按预期进行。
你能建议我一些在 html 文件中使用动画的技术吗,我知道它在同一个地方看起来会很拥挤,但是有可能吗?
如果您唯一的选择是内联编写,我建议使用
<style>
方法。
在 <style></style>
内,您可以在任何 html 文档上编写常规 css
你可以这样做:
<style>
.animate-this {
width: 100px;
height: 100px;
background-color: red;
animation-name: example;
animation-duration: 4s;
}
@keyframes example {
from {
background-color: red;
}
to {
background-color: yellow;
}
}
</style>
<div class="animate-this"></div>