本文实例为大家分享了js仿360开机效果的具体代码,供大家参考,具体内容如下
实现效果:
1.点击关闭图片按钮先往下退出再往右退出
实现步骤:
1.封装运动函数
2.给图片上的关闭设置一个盒子
3.给关闭盒子注册点击事件点击后
4.下面图片高度为0,设置一个缓动动画
5.上面图片宽度为0,设置一个缓动动画
缓动动画代码(带回调函数):`
function getStyle(obj,attr){ //兼容性写法获得样式 if(window.getComputedStyle){ return window.getComputedStyle(obj, null)[attr]; }else{ return obj.currentStyle[attr]; } } function animate(obj, json, speed, callback){ clearInterval(obj.timer); obj.timer = setInterval(function(){ var flag = true; for(var attr in json){ var current = parseInt(getStyle(obj,attr)); var step = (json[attr] - current) / 10; step = step > 0 "htmlcode"><!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8"> <title></title> <style> .box{ width: 322px; position: fixed; bottom:0; right:0; } span{ position: absolute; top:0; right:0; width:30px; height: 20px; cursor: pointer; } .box img{ vertical-align: top; } </style> <script type="text/javascript" src="/UploadFiles/2021-04-02/函数封装.js">效果:
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。
最新资源
- 【中国民乐】张维良《秋江夜泊》2004[FLAC+CUE]
- 明达年度发烧碟MasterSuperiorAudiophile2011[D
- 明达年度发烧碟MasterSuperiorAudiophile2017[D
- 翁立友.2008-恨孤单【大旗】【WAV+CUE】
- 群星.2009-Magic.Cover日粤精华3CD【环球】【WA
- 华少翌.2005-华少翌【中唱艺能】【WAV+CUE】
- 群星《十二女声Ⅱ》[WAV/CUE/分轨][527MB]
- 大自然音乐系列《漫步在山裡》[WAV/CUE/分轨][5
- 大自然音乐系列《星光夜语》[WAV/CUE/分轨][453
- 史依弘《史依弘交响乐京剧演唱专辑HQ》头版限量