返回随机改变颜色,......登陆

随机改变颜色,老师可以测试一下

靖哥哥2018-11-19 16:06:50225

<!DOCTYPE html>

<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>随机颜色</title>

<link rel="stylesheet" href="css/php.css" type="text/css">

<script src="js/jquery-3.3.1.js"></script>

<script src="js/php.js" type="text/javascript"></script>

<style>

/* random */

.random{width: 1200px;margin: 0 auto;background: #ccc;margin-top: 40px;}

.random ul li{width: 100px;height: 100px;color: #000;border-radius: 50%;float: left;margin-right: 10px;line-height: 100px;

text-align: center;}

</style>

<script>

$(function(){

function ran(tag){

var tag1 = document.getElementsByTagName(tag).length;

for(var i=0;i<tag1;i++){

document.getElementsByTagName(tag)[i].style.backgroundColor='rgb('+Math.floor(Math.random()*256)+','+Math.floor(Math.random()*256)+','+

Math.floor(Math.random()*256)+')'

}

}

ran('li');

$('.random ul li').mouseover(function(){

var backg = $(this).css('backgroundColor');

$(this).css('background','backg');

$(this).css({'boxShadow':'0px 0px 20px #ccc','borderRadius':'10px'});

})

$('.random ul li').mouseleave(function(){

var backg = $(this).css('backgroundColor');

$(this).css({'borderRadius':'50%','backgroundColor':'backg','boxShadow':'none'})

})

})

</script>

</head>

<body>

<div class="random">

<ul>

<li>php</li>

<li>php</li>

<li>php</li>

<li>php</li>

<li>php</li>

</ul>

</div>

</body>

</html>


最新手记推荐

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

全部回复(0)我要回复

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