返回随即色点击变色......登陆

随即色点击变色变数字

选择角色2019-03-22 15:37:39334
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>Document</title>
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
</head>
<style>
* {
margin: 0;
padding: 0;
}
body {
font-family: "微软雅黑";
font-size: 18px;
text-align: center;
line-height: 40px;
}
ul,
ol,
li {
list-style: none;
}
div {
width: 100px;
height: 100px;
border-radius: 50px;
text-align: center;
line-height: 100px;
float: left;
cursor: pointer;
margin: 20px;
}
</style>
<body>
<div class="circle"></div>
<div class="circle"></div>
<div class="circle"></div>
<div class="circle"></div>
<script>
(function() {
var aDiv = document.getElementsByClassName("circle");
changeColor();
function changeColor() {
for (var i = 0; i < aDiv.length; i++) {
var r = parseInt(Math.random() * 255),
g = parseInt(Math.random() * 255),
b = parseInt(Math.random() * 255);
aDiv[i].style.background = `rgb(${r},${g},${b})`;
aDiv[i].innerHTML = r + g - b;
}
}
$(".circle").click(function() {
changeColor();
});
$(".circle").mouseover(function() {
$bg = $(this).css("backgroundColor");
$(this).css("box-shadow", "0px 0px 20px " + $bg);
$(this).css("border-radius", "20px ");
});
$(".circle").mouseleave(function() {
$(this).css("box-shadow", "none");
$(this).css("border-radius", "50px ");
});
})();
</script>
</body>
</html>

微信截图_20190322153718.png





最新手记推荐

• 用composer安装thinkphp框架的步骤• 省市区接口说明• 用thinkphp,后台新增栏目• 管理员添加编辑删除• 管理员添加编辑删除

全部回复(0)我要回复

暂无评论~
  • 取消回复发送