当前位置:   article > 正文

html实现验证码效果,CSS+JS验证码效果

刷新验证码让每个字母颜色不同html

00a3c98495828dc2dcbe47cd0220d222.png

HtmlCssJs

验证码

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

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/blog/article/detail/54506
推荐阅读
  • pythonselenium报错】selenium.common.exceptions.WebDriverException:Message:三种解决方案!【pythonselenium报错】selenium.common.excepti... [详细]

  • 网页设计题材,DIV+CSS布局制作,HTML+CSS网页设计期末课程大作业,茶文化网站|中华传统文化题材|京剧文化水墨风书画|中国民间年画文化艺术网站|HTML期末大学生网页设计作业HTML:结构CSS:样式在操作方面上运用了html5和... [详细]

  • 前端登录界面网站设计模板--HTML+CSS... [详细]

  • 大家好,我是yma16,本文分享关于前端富文本编辑器原理——从javascripthtml、css开始。富文本编辑器富文本编辑器是指具有格式化文本和图像编辑功能的文本编辑器Contenteditable属性Contenteditable是... [详细]

  • Vue(发音为/vjuː/,类似view)是一款用于构建用户界面的JavaScript框架。它基于标准HTMLCSS和JavaScript构建,并提供了一套声明式的、组件化的编程模型,帮助你高效地开发用户界面。无论是简单还是复杂的界面,Vu... [详细]

  • CSS颜色与背景颜色color属性背景background属性1.背景颜色background-color2.背景图像background-image3.背景图像平铺方式background-repeat4.固定/滚动背景图像backgro... [详细]

  • 本文实现,uniapp微信小程序,把页面内容保存为图片,并且下载到手机上,说实话网上找了很多资料,但是效果不理想,直到看了一个开源项目,我知道可以实现了,本文以开源项目uniapp-wxml-to-canvas为蓝本记录集成的步骤,以供参考... [详细]

  • 表格 表格 表格标记 表格标记-语法 表格属性设置 表格边框样式属性 表格单元格间距、单元格边距属性 表格水平对齐 设置表格行的属性 表格行的属性-设置 设置单元格的属性 设置单元格的属性-单元格跨行、列 表格嵌套课后练习网页标题:计算机报... [详细]

  • 作者:ManishChampaneriGolang可视化库sciter这是来自sciter网站的几句话,sciter桌面UI开发带来了一系列网页技术。网页设计者和开发者可以复用他们的经验和专长来构建看起来现代的桌面应用。多种多样的GUI框架... [详细]

  • 面试必备八股文!内容包含:Java基础、Java框架、Git命令、JVM、多线程、消息队列、微服务、Linux、数据库、Redis缓存、算法、Vue、React、前端性能优化等八股文面试HTML框架八股文十问十答第一期面试HTML框架八股... [详细]

  • 炫酷登录注册界面【超级简单 jQuery+JS+HTML+CSS实现】_html登录页面代码
    炫酷登录注册界面【超级简单jQuery+JS+HTML+CSS】_html登录页面代码html登录页面代码一:源码获取这两天根据需求写了一个比较好看的有动态效果的登录注册切换页面,这里我将源码资源分享给大家,大家可以直接免费下载使用哦,没有... [详细]

  • 嗨,朋友们!准备好开始一段令人兴奋的数字冒险吗?让我们从HTML的神秘世界开始吧。HTML,或者说超文本标记语言,不仅仅是编程的一种语言,它更像是网页的魔法咒语。每当你在网冲浪,浏览各种炫酷的网站时,其实你正在经历HTML的魔法。《HTM... [详细]

  • 现在,想象你在为一款新产品制作介绍页面。你想要清晰地展示产品名称、特点用户评价。DOCTYPEhtml>超级充电宝<body><h<em>2</em>>超级充电宝<p>这款<strong>超级充电宝可以在短短30分钟... <a title="《HTML 简易速速上手小册》第2章:HTML 的标签和元素(2024 最新版)" href="/blog/article/detail/44550" target="_blank">[详细]</a></div><div style="clear: both;"></div></div><div class="article_click rice1" style="width: 140px;"><p class="operation-b-img operation-b-img-active"><i class="img-up txclick" attc="upclick" attn="0"></i><span class="num"> 赞</span></p><p class="operation-b-img operation-b-img-active"><i class="img-down txclick" attc="downclick" attn="0"></i><span class="num">踩</span></p></div></li><li><div class="NewTitle"><a title="article" class="cat" href="/blog/article/list/1" target="_blank">article<i></i></a><h2><a title="【HTML 基础】元素和标签" href="/blog/article/detail/44564" target="_blank">【<em>HTML</em> <em>基础</em>】<em>元素</em>和<em>标签</em></a></h2></div><div class="NewsInfo"><div class="NewsDesc" style="width: 100%; ">这只是<em>HTML</em>中一小部分常见<em>标签</em>的介绍。了解这些<em>基础</em><em>标签</em>是构建网页的第一步。随着你深入学习,你将发现<em>HTML</em>提供了丰富的<em>标签</em>,用于定义文档的结构、内容和样式。继续学习<em>HTML</em>,打造令人印象深刻的Web页面吧!【<em>HTML</em><em>基础</em>】<em>元素</em>和<em>标签</em>文章目... <a title="【HTML 基础】元素和标签" href="/blog/article/detail/44564" target="_blank">[详细]</a></div><div style="clear: both;"></div></div><div class="article_click rice1" style="width: 140px;"><p class="operation-b-img operation-b-img-active"><i class="img-up txclick" attc="upclick" attn="0"></i><span class="num"> 赞</span></p><p class="operation-b-img operation-b-img-active"><i class="img-down txclick" attc="downclick" attn="0"></i><span class="num">踩</span></p></div></li><li><div class="NewTitle"><a title="article" class="cat" href="/blog/article/list/1" target="_blank">article<i></i></a><h2><a title="HTML — 样式 CSS" href="/blog/article/detail/44567" target="_blank"><em>HTML</em> — 样式 <em>CSS</em></a></h2></div><div class="NewsInfo"><div class="NewsDesc" style="width: 100%; "><em>CSS</em>是从<em>HTML</em>4开始使用的,是为了更好的渲染<em>HTML</em>元素而引入的。<em>HTML</em>—样式<em>CSS</em>一.使用    <em>CSS</em>是从<em>HTML</em>4开始使用的,是为了更好的渲染<em>HTML</em>元素而引入的。  ... <a title="HTML — 样式 CSS" href="/blog/article/detail/44567" target="_blank">[详细]</a></div><div style="clear: both;"></div></div><div class="article_click rice1" style="width: 140px;"><p class="operation-b-img operation-b-img-active"><i class="img-up txclick" attc="upclick" attn="0"></i><span class="num"> 赞</span></p><p class="operation-b-img operation-b-img-active"><i class="img-down txclick" attc="downclick" attn="0"></i><span class="num">踩</span></p></div></li><li><div class="NewTitle"><a title="article" class="cat" href="/blog/article/list/1" target="_blank">article<i></i></a><h2><a title="http:/222.212.79/app/zscd.html,emscripten/src/shell.html at 1.29.12 · emscripten-core/emscripten · G..." href="/blog/article/detail/46259" target="_blank"><em>http</em>:/222.2<em>12</em>.79/app/<em>zscd</em>.<em>html</em>,<em>emscripten</em>/src/shell.<em>html</em> at <em>1.29</em>.<em>12</em> · <em>emscripten</em>-core/<em>emscripten</em> · G...</a></h2></div><div class="NewsInfo"><div class="NewsDesc" style="width: 100%; ">version="1.1"id="Layer_1"x="0px"y="0px"width="296px"height="78px"viewBox="420<em>12</em>0100170"enable-background="new00900400"xm... <a title="http:/222.212.79/app/zscd.html,emscripten/src/shell.html at 1.29.12 · emscripten-core/emscripten · G..." href="/blog/article/detail/46259" target="_blank">[详细]</a></div><div style="clear: both;"></div></div><div class="article_click rice1" style="width: 140px;"><p class="operation-b-img operation-b-img-active"><i class="img-up txclick" attc="upclick" attn="0"></i><span class="num"> 赞</span></p><p class="operation-b-img operation-b-img-active"><i class="img-down txclick" attc="downclick" attn="0"></i><span class="num">踩</span></p></div></li><li><div class="NewTitle"><a title="article" class="cat" href="/blog/article/list/1" target="_blank">article<i></i></a><h2><a title="HTML-表单" href="/blog/article/detail/47688" target="_blank"><em>HTML</em>-<em>表单</em></a></h2></div><div class="NewsInfo"><div class="NewsDesc" style="width: 100%; ">概念:一个包含交互的区域,用于收集用户提供的数据。示例代码:2.常用<em>表单</em>控件1.文本输入框2.密码输入框3.单选框4.复选框5.下拉框6.隐藏域7.提交按钮8.重置按钮9.普通按钮10.文本域3.禁用<em>表单</em>控件给<em>表单</em>控件的标签设置disabl... <a title="HTML-表单" href="/blog/article/detail/47688" target="_blank">[详细]</a></div><div style="clear: both;"></div></div><div class="article_click rice1" style="width: 140px;"><p class="operation-b-img operation-b-img-active"><i class="img-up txclick" attc="upclick" attn="0"></i><span class="num"> 赞</span></p><p class="operation-b-img operation-b-img-active"><i class="img-down txclick" attc="downclick" attn="0"></i><span class="num">踩</span></p></div></li><li><div class="NewTitle"><a title="article" class="cat" href="/blog/article/list/1" target="_blank">article<i></i></a><h2><a title="HTML-CSS笔记_0424_,~ghj dyuouup" href="/blog/article/detail/48522" target="_blank"><em>HTML</em>-<em>CSS</em>笔记<em>_</em>0424<em>_</em>,~<em>ghj</em> <em>dyuouup</em></a></h2></div><div class="NewsInfo"><div class="NewsDesc" style="width: 100%; ">2、文档声明3、注释和标签属性4、实体5、meta便签5、语义化标签6、语义化标签7、语义化标签8、list标签9、超链接10、相对路径11、超链接12、images图片标签13、内联框架14、音频播放<em>CSS</em>二、<em>CSS</em>基础1、<em>CSS</em>简介外部... <a title="HTML-CSS笔记_0424_,~ghj dyuouup" href="/blog/article/detail/48522" target="_blank">[详细]</a></div><div style="clear: both;"></div></div><div class="article_click rice1" style="width: 140px;"><p class="operation-b-img operation-b-img-active"><i class="img-up txclick" attc="upclick" attn="0"></i><span class="num"> 赞</span></p><p class="operation-b-img operation-b-img-active"><i class="img-down txclick" attc="downclick" attn="0"></i><span class="num">踩</span></p></div></li><li><div class="NewTitle"><a title="article" class="cat" href="/blog/article/list/1" target="_blank">article<i></i></a><h2><a title="2018-04-21-linux-sources-list html-url、隐藏滚动条_s36ncqqh.xyz" href="/blog/article/detail/48608" target="_blank">2018-04-21-<em>linux</em>-<em>sources</em>-<em>list</em> <em>html</em>-url、隐藏滚动条_<em>s36ncqqh</em>.xyz</a></h2></div><div class="NewsInfo"><div class="NewsDesc" style="width: 100%; ">titlelayoutcategoriestagsexcerptKaliLinux之软件安装、卸载、更新和修改更新源postLinuxLinux安装软件Linux更新源Linux系统软件安装、卸载、更新与修改更新源使用Linux系统,与Wi... <a title="2018-04-21-linux-sources-list html-url、隐藏滚动条_s36ncqqh.xyz" href="/blog/article/detail/48608" target="_blank">[详细]</a></div><div style="clear: both;"></div></div><div class="article_click rice1" style="width: 140px;"><p class="operation-b-img operation-b-img-active"><i class="img-up txclick" attc="upclick" attn="0"></i><span class="num"> 赞</span></p><p class="operation-b-img operation-b-img-active"><i class="img-down txclick" attc="downclick" attn="0"></i><span class="num">踩</span></p></div></li><li><div class="NewTitle"><a title="article" class="cat" href="/blog/article/list/1" target="_blank">article<i></i></a><h2><a title="[HTML]Web前端开发技术12(HTML5、CSS3、JavaScript )——喵喵画网页" href="/blog/article/detail/49178" target="_blank">[<em>HTML</em>]Web<em>前端开发</em>技术12(<em>HTML</em>5、<em>CSS3</em>、<em>JavaScript</em> )——喵喵画<em>网页</em></a></h2></div><div class="NewsInfo"><div class="NewsImg"><a title="[HTML]Web前端开发技术12(HTML5、CSS3、JavaScript )——喵喵画网页" href="/blog/article/detail/49178" target="_blank"><img width="120" height="70" alt="[HTML]Web前端开发技术12(HTML5、CSS3、JavaScript )——喵喵画网页" src="https://csdnimg.cn/release/cmsfe/public/img/lazyLogo2.1882d7f4.png"></a></div><div class="NewsDesc" style="width: 100%; "><em>网页</em>标题:三列自适应宽度<em>网页</em>标题:多行三列自适应宽度一级水平导航菜单:采用“无序列表+超链接”设计[<em>HTML</em>]Web<em>前端开发</em>技术12(<em>HTML</em>5、<em>CSS3</em>、<em>JavaScript</em>)——喵喵画<em>网页</em>希望你开心,希望你健康,希望你幸福,希望你点赞!... <a title="[HTML]Web前端开发技术12(HTML5、CSS3、JavaScript )——喵喵画网页" href="/blog/article/detail/49178" target="_blank">[详细]</a></div><div style="clear: both;"></div></div><div class="article_click rice1" style="width: 140px;"><p class="operation-b-img operation-b-img-active"><i class="img-up txclick" attc="upclick" attn="0"></i><span class="num"> 赞</span></p><p class="operation-b-img operation-b-img-active"><i class="img-down txclick" attc="downclick" attn="0"></i><span class="num">踩</span></p></div></li></ul><div class="list_tools_top">相关标签</div><div class="list_tools_box"><ul><li><a title="python" rel="nofollow" href="/s?w=python" target="_self">python</a></li><li><a title="selenium" rel="nofollow" href="/s?w=selenium" target="_self">selenium</a></li><li><a title="开发语言" rel="nofollow" href="/s?w=开发语言" target="_self">开发语言</a></li><li><a title="javascript" rel="nofollow" href="/s?w=javascript" target="_self">javascript</a></li><li><a title="html" rel="nofollow" href="/s?w=html" target="_self">html</a></li><li><a title="css" rel="nofollow" href="/s?w=css" target="_self">css</a></li><li><a title="前端" rel="nofollow" href="/s?w=前端" target="_self">前端</a></li><li><a title="dreamweaver" rel="nofollow" href="/s?w=dreamweaver" target="_self">dreamweaver</a></li><li><a title="登录表单" rel="nofollow" href="/s?w=登录表单" target="_self">登录表单</a></li><li><a title="登录" rel="nofollow" href="/s?w=登录" target="_self">登录</a></li><li><a title="富文本编辑器" rel="nofollow" href="/s?w=富文本编辑器" target="_self">富文本编辑器</a></li><li><a title="vue.js" rel="nofollow" href="/s?w=vue.js" target="_self">vue.js</a></li><li><a title="vue" rel="nofollow" href="/s?w=vue" target="_self">vue</a></li><li><a title="html5" rel="nofollow" href="/s?w=html5" target="_self">html5</a></li><li><a title="css3" rel="nofollow" href="/s?w=css3" target="_self">css3</a></li><div style="clear: both;"></div></ul></div><div class="list_tools_top"></div></div></div></div><style type="text/css"></style><link rel="stylesheet" href="https://cdn.wpsshop.cn/public/blog/css/phone.css?v=13352890" type="text/css"><script type="text/javascript"></script></div></div></div></div></div><!--row_1_b100_1695--></div><style type="text/css"> /* footer css */ .index006-cover-page-foot { background-color: #F7F7F7; } </style><link rel="stylesheet" href="https://cdn.wpsshop.cn/public/ads/css/ads.css?v=12890" type="text/css"><script type="text/javascript" src="https://cdn.wpsshop.cn/public/ads/js/ads.js?v=1890" ></script><div class="cppui-row-1_100 cppui-row-view-1 row_1_100 ui-draggable" style="display: block;"><div class="cppui-column-1_100-0-1 column-view-com cppui-column-1_100-0-view-1 ui-sortable"><div class="drag-item-show-view-1 footermsg_view_pic ui-draggable" style="display: block;"><!--组件最外层要添加 drag-item-hide-view-1 --><div class="index006-cover-page-foot drag-item-hide-view-1"><p class="copyright">Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。 </p><div style="background-color:#F7F7F7; text-align:center; height:20px;padding-top:5px;"><a target="_blank" href="https://beian.mps.gov.cn/#/query/webSearch" style="display:inline-block;text-decoration:none;height:20px;line-height:20px;"><img src="https://cdnimages.wpsshop.cn/57public/skin/index/default/ui/images/beian_ghs.png" style="float:left;">  <p style="float:left;height:20px;line-height:20px;margin: 0px 0px 0px 5px; color:#939393;">闽ICP备14008679号</p></a>  <a href="https://www.wpsshop.cn/xml/article/detail/54506.xml" target="_blank" style="display:inline-block;text-decoration:none;height:20px;line-height:20px;"><img src="https://cdn.wpsshop.cn/public/blog/images/site.png" style="float:left;"></a>   <a href="/xml/w/g007/article/detail/new.xml" target="_blank" style="display:inline-block;text-decoration:none;height:20px;line-height:20px;"><img src="https://cdn.wpsshop.cn/public/blog/images/site.png" style="float:left;"></a>   <a href="/site.xml" target="_blank" style="display:inline-block;text-decoration:none;height:20px;line-height:20px;"><img src="https://cdn.wpsshop.cn/public/blog/images/site.png" style="float:left;"></a></div></div></div></div><!--row_1_b100_hcsoft_1693--></div><!--tjcode0088--><script type="text/javascript">var domain = document.domain;var hr=encodeURIComponent(window.location.href+'=='+document.referrer); document.write('<script src="https://ad.wpsshop.cn/admin.appflux?s=ad_flu_ind&fluxuserauto=yes&hr='+hr+'&p57weburl='+domain+'&p57usercode1='+domain+'&u=Vy1RJQhqAXUEMQNnAm0HaVVu&i='+p57ref("id")+'&r='+escape(document.referrer)+'" language="JavaScript"><\/script>');function p57ref(id){var reg=new RegExp("(^|&)"+id+"=([^&]*)(&|$)");var ref=window.location.search.substr(1).match(reg);if(ref!=null)return unescape(ref[2]);return null;} </script><!--tjcode0088--></body></html>