帮助中心
获取牛币
联系我们
关于我们
版权声明
素材牛首页
微博登录
QQ登录
微信扫码登录
注册
登录
新浪微博
QQ登陆
微信登录
热门搜索:
小程序
支付
Java
后台模板
上传
商城模板
jQuery
手机
Thinkphp
微信
Vue.js
首 页
网页特效
整站源码
PHP实例
网站模版
工具箱
常用代码
论坛
游戏源码
资源分享
当前位置:
首页
»
精选常用代码
» CSS+JS验证码效果
CSS+JS验证码效果
浏览:1256次
-
评论:0次
-
发布时间:2018-08-18
Html
Css
Js
验证码
5c1q
body,html { height:100%; display:flex; justify-content:center; align-items:center; background:rgb( 131,247,131) } main { width:300px; height:150px; /* 定义边框大小 样式,此处为配合下面的边框渐变效果所以不加颜色 */ border:0px solid; /* 定义边框渐变样式 */ border-image:linear-gradient( -45deg,white 50%,greenyellow 50%,greenyellow 100%) 30 30; display:flex; align-items:center; justify-content:center; /* 定义标签边框属性 */ box-sizing:border-box; transition:0.5s; } main:hover { border:25px solid; border-image:linear-gradient( -45deg,white 50%,greenyellow 50%,greenyellow 100%) 30 30; } #ma { width:250px; height:100px; /* background:red;*/ position:relative; } section { width:150px; height:100px; background:white; position:absolute; left:50px; z-index:100; font-size:25px; font-weight:bold; text-align:center; line-height:100px; /* 设置字符之间有0.2em的空隙间隔 */ letter-spacing:0.2em; cursor:pointer; /* 定义标签背景渐变 */ background:linear-gradient( -45deg,white 50%,greenyellow 50%,greenyellow 100%) color:rgb( 170,170,167) transition:0.5s; animation:dong 0.1s linear infinite alternate; } @keyframes dong { 0% { transform:translateX( -10px) } 50% { transform:translateX( 0px) } 100% { transform:translateX( 10px) } }main:hover section { opacity:0; z-index:87; transform:scale( 1.5) animation-play-state:paused; } .ma { width:150px; height:100px; background:white; position:absolute; left:50px; z-index:99; /* 设置过渡的返回时间 */ transition-duration:0.5s; text-align:center; line-height:100px; font-size:35px; letter-spacing:0.2em; cursor:default; opacity:0; color:transparent; /* 定义字符内的字母都是大写 */ text-transform:uppercase; font-family:-apple-system,BlinkMacSystemFont,' Segoe UI',Roboto,Oxygen,Ubuntu,Cantarell,' Open Sans',' Helvetica Neue',sans-serif; } main:hover .ma { transition:0.7s ease-in-out; left:0; opacity:1; color:rgb( 85,84,84) } #refresh { width:100px; height:100px; position:absolute; right:50px; z-index:88; transition-duration:0.5s; border:18px solid transparent; background:greenyellow; font-size:25px; color:white; cursor:pointer; box-sizing:border-box; opacity:0; } #refresh:hover { border:0px solid white; } main:hover #refresh { transition:0.7s ease-in-out; right:0; opacity:1; }
var refresh = document.getElementById('refresh'); var ma = document.getElementsByClassName('ma')[0]; // 定义一个包含数字和26个字母的数组 var arr = ['1', 'a', '2', 'b', '3', 'c', '4', 'd', '5', 'e', '6', 'f', '7', 'g', '8', 'h', '9', 'i', '0', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']; //创建一个能够生成随机数的方法 function f1() { // 定义四个不同的随机数 var num1 = Math.floor(Math.random() * 36); var num2 = Math.floor(Math.random() * 36); var num3 = Math.floor(Math.random() * 36); var num4 = Math.floor(Math.random() * 36); //把生成的四个随机数连到一起 var random = arr[num1] + arr[num2] + arr[num3] + arr[num4]; //把生成的随机数字符替换到 .ma 的标签内 ma.innerHTML = random; } //调用方法,生成随机数,替换掉之前写好的 5c1q 字符 f1(); // 通过点击刷新按钮调用 random() 方法 refresh.onclick = function random() { // 每点击一次,调用一次 f1()方法,即生成一个随机数 f1(); }
↑上面代码改变,会自动显示代码结果
jQuery调用版本:
1.11.3
<!doctype html><html><head><meta charset="utf-8"><title>CSS+JS验证码效果-www.sucainiu.com</title><script src="https://libs.baidu.com/jquery/1.11.3/jquery.min.js"></script><style>
</style></head><body>
<script>
</script>
</body></html>
立即下载
收藏
积分说明:注册即送10牛币,每日签到可获得5牛币,成为VIP会员可永久免牛币下载!
充值积分
充值会员
更多说明»
代码描述:通过css和简单的js方法调用实现随机生成的验证码
鼠标经过,验证码滑开,点击刷新,再次生成随机验证码
CSS3+3D相册效果
定位提示框效果
讨论这个常用代码(0)
回答他人问题或分享心得会奖励牛币
〒_〒 居然一个评论都没有……
文明上网,理性发言! 😉 阿里云幸运券,
戳我领取
发表评论
提交回复
我的积分余额:
0
已下载次数:
1256
所需牛币:
5
开始下载
牛币获取:
签到、评论、充值
» 在线充值
(10牛币=1元)
成为VIP可永久免积分下载全部常用代码
» 查看详情
VIP
客服
签到
充值