gpt4 book ai didi

html - html中的CSS动画

转载 作者:行者123 更新时间:2023-11-27 23:35:17 25 4
gpt4 key购买 nike

我有在页面加载时播放的 html 动画。

<div class="animated bounceInUp zoomin" style="text-align:center;">

<img src="butonwater.png" onclick="" width="200px" height="200px">
</div>
<script>

bounceInUp 是我样式表中的 CSS 动画。如何从样式表 onclick 播放动画?

最佳答案

Working Plunker

有几种方法可以使用 onclick 重新启动动画。 Chris Coyier 有一个 good post对此。

Javascript

function bounceAgain() {
var el = document.getElementById("test");
el.classList.remove('bounceInUp');
el.offsetWidth = el.offsetWidth;
el.classList.add('bounceInUp');
}

HTML

添加 bounceAgain()onclick

<div class="animated bounceInUp zoomin" style="text-align:center;">
<img src="http://i.imgur.com/alhBkw5.png" onclick="bounceAgain()" width="300px" height="200px">
</div>

关于html - html中的CSS动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34079884/

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