是的,animate.style支持鼠标悬停动画,可以用以下示例代码实现:
HTML:
CSS: .box { width: 100px; height: 100px; background-color: red; animation-duration: 1s; animation-name: example; animation-direction: alternate; animation-fill-mode: forwards; }
@keyframes example { from { transform: scale(1); } to { transform: scale(1.2); } }
.box:hover { animation-name: example-hover; }
@keyframes example-hover { from { transform: scale(1); } to { transform: scale(1.5); } }
以上代码将在鼠标悬停时将元素放大,动画持续时间为1秒。当鼠标离开时,元素将恢复正常状态。
注意:animate.style对于鼠标悬停动画的支持可能受浏览器兼容性影响,建议在不同浏览器和设备上进行测试。