鼠标点击按钮产生动画效果jQuery

2025-10-22 18:00:23

1、新建html文档。

鼠标点击按钮产生动画效果jQuery

2、书写hmtl代码。

<div id="heading"> <br>

  <br>

  <br>

  <h1>鼠标点击按钮产生动画效果jQuery特效</h1>

</div>

<div style="margin-top:70px; text-align:center"> <a id="btn" class="button" href="#">Default mation</a> <br>

  <br>

  <br>

  <br>

  <br>

  <a id="btn2" class="button" href="#">Tick Animation</a> <a id="btn3" class="button" href="#">Cross mation</a> <br>

  <br>

  <br>

  <br>

  <br>

  <a id="btn4" class="button" href="#">Signal Animation</a> <a id="btn5" class="button" href="#">Shoot mation</a> </div>

鼠标点击按钮产生动画效果jQuery

3、书写css代码。

@font-face { font-family: "Montserrat"; src: url('../fonts/Montserrat.otf'),  url('../fonts/Montserrat.otf'); /* IE */ }

body { height: 100%; margin: 0; padding: 0; font-family: Montserrat; text-align: center; background-color: rgb(0,51,51); overflow-x: hidden; }

#menu { background-color: rgb(0,0,0); text-align: left; color: rgb(204,204,204); padding: 10px; padding-left: 40px; }

#menu a { padding-left: 20px; padding-right: 20px; text-decoration: none; color: rgb(204,204,204); }

#footer { width: 100%; position: fixed; bottom: 0; background-color: rgb(0,0,0); text-align: center; font-size: 10px; color: rgb(204,204,204); padding: 5px; }

#heading { color: rgb(255,255,255); }

.button { width: 100px; color: rgb(255,255,255); border: rgb(255,255,255) solid; border-radius: 15px; padding: 15px; text-decoration: none; }

.button:hover { background-color: rgb(255,255,255); color: rgb(51,51,51); transition: ease-in-out .5s; }

鼠标点击按钮产生动画效果jQuery

4、书写并添加js代码。

<script src="js/jquery-1.12.0.min.js"></script>

<script src="js/animateClick.js"></script>

<script>

$(document).ready(function() {

$('#btn').an  imateClick({

"color":"black"

});

$('#btn2').ani  mateClick({

"color":"green",

"ani  mation":"tick"

});

$('#btn3').ani  mateClick({

"color":"red",

"animation":"cross"

});

$('#btn4').ani  mateClick({

"color":"grey",

"animation":"signal"

});

$('#btn5').mateClick({

"color":"lightblue",

"mation":"shoot"

});

});

</script>

鼠标点击按钮产生动画效果jQuery

5、代码整体结构。

鼠标点击按钮产生动画效果jQuery

6、查看效果。

鼠标点击按钮产生动画效果jQuery

声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
猜你喜欢