js实现图形验证码
html
js
<script type="text/javascript">var code;window.onload = function css() {createCode();}function createCode() {code = "";var codeLength = 4; //驗證碼的長度var codes = document.getElementById("codes");var charNum= new Array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9,'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z','A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'); //隨機數(shù)(包括中文)for (var i = 0; i < codeLength; i++) {var Name = Math.floor(Math.random() * 52);code += charNum[Name];}if (codes) {codes.className = "code";codes.innerHTML = code;}} </script>css
.phone {width: 90%;height: 40px;margin: auto;border-radius: 20px;background: #40B450;display: flex;align-items: center;margin-top: 20px;}.phones {width: 76%;display: flex;}.yan {width: 80px;height: 40px;background: #B3E1B9;color: #178226;font-size: 14px;display: flex;align-items: center;justify-content: center;border-radius: 0 20px 20px 0;}.code {font-style: italic;color: #178226;font-size: 16px;padding: 2px 3px;letter-spacing: 3px;font-weight: bolder;line-height: 60px;text-align: center;}總結(jié)
- 上一篇: Ubuntu 12.10 正式发布
- 下一篇: 家长必看 父母须知孩子社交圈九要点(组图