摘要:
Document* {
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;
}
(function() {
var aDiv = document.getElementsByClassName("circle");
changeColor();
function changeColor() {
for (var i = 0; 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 ");
});
})();
批改老师:灭绝师太批改时间:2019-03-22 15:47:28
老师总结:最好做个点击按钮,也可以试着用不同于上课案例的方法来完成哦!