html+css+js粘土动画Doodle特效

2025-05-14 03:21:18

1、准备好需要用到的图标。

html+css+js粘土动画Doodle特效html+css+js粘土动画Doodle特效html+css+js粘土动画Doodle特效

2、新建html文档。

html+css+js粘土动画Doodle特效

4、书写css代码。<style>div{position:absolute;}</style>

html+css+js粘土动画Doodle特效

6、书写animationjs代码<script>function animation(options) { var defau造婷用痃ltOptions = { element: "", url: "", speed: 11, hover: function () { }, blur: function () { } }; this.init(options, defaultOptions);};animation.prototype = { init: function (o1, o2) { var me = this; for (var p in o2) { me[p] = o1[p] || o2[p]; } me.element = document.getElementById(me.element); me.delay = 1000 / me.speed; me.step = 0; me.defaultBackground = me.element.style.background; me.defalutUrl = me.element.style.backgroundImage; me.url = me.url || me.defalutUrl; me.width = me.element.clientWidth; me.height = me.element.clientHeight; var img = new Image(); img.onload = function () { me.cols = parseInt(img.width / me.width); me.rows = parseInt(img.height / me.height); me.frames = me.cols * me.rows; me.element.onclick = function () { me.play(); }; me.element.onmouseover = function () { me.onhover(); }; me.element.onmouseout = function () { me.onblur(); }; }; img.src = me.url; }, play: function () { if (this.playing) { return; } this.playing = true; this.next();}, onhover: function () { if (!this.playing) { this.hover(); } }, onblur: function () { if (!this.playing) { this.blur(); } }, next: function () { var me = this; me.step++; if (me.step > me.frames) { me.stop(); return; } var x = me.step % me.cols; var y = parseInt(me.step / me.rows); if (me.step % me.rows > 0) { y++; } var position = "-" + (x - 1) * me.width + "px -" + (y - 1) * me.height + "px"; me.element.style.background = "url(" + me.url + ") " + position; setTimeout(function () { me.next(); }, me.delay); }, stop: function () { var me = this; me.step = 0; me.playing = false; me.element.style.background = me.defaultBackground; }};</script>

html+css+js粘土动画Doodle特效

8、查看效果。

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