js运动
1.![](https://images2018.cnblogs.com/blog/1430556/201808/1430556-20180814175956257-1457578722.gif)
![](https://images2018.cnblogs.com/blog/1430556/201808/1430556-20180814175956257-1457578722.gif)
<!DOCTYPE html> <html > <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>发送验证码倒计时功能</title> <style> @charset "utf-8"; *{ margin:0; padding:0; list-style:none} body{ background:#EBECED; font-family:'微软雅黑'} .form{width: 450px;height: auto; margin:100px auto; overflow:hidden;font-size: 16px;color: #1b1b1b;text-align: left; padding:50px; border:1px solid #ccc; border-radius:10px;} .form div{padding:5px 0;overflow: hidden;} .form label{width: 90px;display: block;float: left;} .form .infos{width:200px;height: 26px;line-height: 26px;border:1px solid #BFBFBF;padding:2px;border-radius:4px;float: left;} .form .div-phone a.send1{height: 26px;text-decoration:none;line-height: 26px;padding:2px;width: 80px;background: #AA8926;font-family: '宋体';color: #fff;font-size: 12px;text-align: center;display: block;float: left;border-radius:2px;margin-left:2px;-webkit-transition:all 0.2s linear;-moz-transition:all 0.2s linear;-ms-transition:all 0.2s linear;-o-transition:all 0.2s linear;transition:all 0.2s linear;} .form .div-phone a.send1:hover{text-decoration: none;background: #866c1b;-webkit-transition:all 0.2s linear;-moz-transition:all 0.2s linear;-ms-transition:all 0.2s linear;-o-transition:all 0.2s linear;transition:all 0.2s linear;} .form .div-phone a.send0{height: 26px;text-decoration:none;line-height: 26px;padding:2px;width: 80px;background: #A1A1A1;font-family: '宋体';color: #fff;font-size: 12px;text-align: center;display: block;float: left;border-radius:2px;margin-left:2px;} .form .div-phone a.send0:hover{background: #A1A1A1;font-family: '宋体';color: #fff;font-size: 12px;text-decoration: none;} .form span.error{height: 26px;line-height: 26px;padding:2px;width: 100px;color: red;padding-left:20px;display: block;float: left;margin-left:10px;font-size: 12px;font-family: '宋体';background: url(../images/error.png) no-repeat left center;} .form #phone{width: 116px;} .form .div-conform{padding-right:153px;} .form .div-conform a.conform{width: 136px;height: 34px;display: block;text-align: left;overflow: hidden;background: url(../images/btn.jpg) no-repeat;float: right;text-indent: -1000px;} </style> </head> <body> <!--代码部分begin--> <div class="form"> <div class="div-name"> <label for="name">用户名</label><input type="text" id="name" class="infos" placeholder="请输入用户名" /> </div> <div class="div-phone"> <label for="phone">手机</label><input type="text" id="phone" class="infos" placeholder="请输入手机" /> <a href="javascript:;" rel="external nofollow" rel="external nofollow" class="send1" onclick="sends.send();">发送验证码</a> </div> <div class="div-ranks"> <label for="ranks">验证码</label><input type="text" id="ranks" class="infos" placeholder="请输入验证码" /> </div> <div class="div-conform"> <a href="javascript:;" rel="external nofollow" rel="external nofollow" class="conform" onclick="sends.conform();">提交</a> </div> </div> <script src="http://www.lanrenzhijia.com/ajaxjs/jquery.min.js"></script> <script> var sends = { checked:1, send:function(){ var numbers = /^1\d{10}$/; var val = $('#phone').val().replace(/\s+/g,""); //获取输入手机号码 if($('.div-phone').find('span').length == 0 && $('.div-phone a').attr('class') == 'send1'){ if(!numbers.test(val) || val.length ==0){ $('.div-phone').append('<span class="error">手机格式错误</span>'); return false; } } if(numbers.test(val)){ var time = 30; $('.div-phone span').remove(); function timeCountDown(){ if(time==0){ clearInterval(timer); $('.div-phone a').addClass('send1').removeClass('send0').html("发送验证码"); sends.checked = 1; return true; } $('.div-phone a').html(time+"S后再次发送"); time--; return false; sends.checked = 0; } $('.div-phone a').addClass('send0').removeClass('send1'); timeCountDown(); var timer = setInterval(timeCountDown,1000); } } } </script> </body> </html>
2.![]()
![](https://images2018.cnblogs.com/blog/1430556/201808/1430556-20180814180028275-265594676.gif)
![](https://images2018.cnblogs.com/blog/1430556/201808/1430556-20180814180028275-265594676.gif)
<!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <title>进度条</title> <style> * { margin: 0; padding: 0; } #outer { margin: 50px auto; padding: 10px; width: 600px; background: #eee; } #inner { width: 0; text-align: center; line-height: 30px; background: #0b80f7; overflow: hidden; } </style> </head> <body> <div id="outer"> <div id="inner">0%</div> </div> <script> var oInner = document.getElementById('inner'); var target = 600; var timer = setInterval( function () { // 进度条的宽度 = 进度条的当前的实际宽度 + 10 +'px'; oInner.style.width = oInner.offsetWidth + 10 +'px'; // 改变当前进度条的百分比 oInner.innerHTML = Math.round(oInner.offsetWidth / target * 100) + '%'; //当进度到达最大值时。清除定时器 if(oInner.offsetWidth >= target){ clearInterval(timer); } },100); </script> </body> </html>
3.
抛物线运动
![](https://images2018.cnblogs.com/blog/1430556/201808/1430556-20180814180117917-1354000227.gif)
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>抛物线</title> <style> body{ height: 500px; background: #0ff; } *{ margin: 0; padding: 0; } #yellow{ width:100px; height: 100px; border-radius: 50%; position: absolute; background: yellow; top:500px; } </style> </head> <body> <div id="yellow"></div> <script> var oY = document.getElementById('yellow'); var speedX = oY.offsetWidth; var speedY = oY.offsetHeight; var maxL = document.documentElement.clientWidth - oY.offsetWidth; var maxT = document.documentElement.clientHeight - oY.offsetHeight; oY.timer = setInterval(function(){ var nextX = oY.offsetLeft + speedX; var nextY = oY.offsetTop - speedY; if(nextX >= maxL){ nextX = maxL; speedX *= -1;//往反方向运动 } if(nextX <= 0){ nextX = 0; speedX *= -1; speedY *= -1; } //下 if(nextY >= maxT){ nextY = maxT; } //上 if(nextY <= 0){ nextY = 0; speedY *= -1; } oY.style.left = nextX + 'px'; oY.style.top = nextY + 'px'; },100); </script> </body> </html>
作者:狗尾草
-------------------------------------------
个性签名:海到无边天作岸,山登绝顶人为峰!
如果觉得这篇文章对你有小小的帮助的话,记得在右下角点个“推荐”哦,博主在此感谢!