<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style type="text/css">
*{
margin: 0;
padding: 0;
}
li{
list-style: none;
width: 200px;
height: 500px;
float: left;
transition: all .3s;
}
#box{
width: 1000px;
height: 500px;
border: 1px solid red;
margin: 0 auto;
overflow: hidden;
}
</style>
<script src="jquery-3.4.1.min.js"></script>
</head>
<body>
<ul id="box">
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
</ul>
<script type="text/javascript">
$(function(){
function color(){
var r=Math.floor(Math.random()*256);
var g=Math.floor(Math.random()*256);
var b=Math.floor(Math.random()*256);
var rgb='rgb('+r+','+g+','+b+')';
return rgb;
}
$('#box li').each(function(index,e){
$(this).css({
'background':color,
})
})
$('#box li').hover(function(){
$(this).width(400);
$(this).siblings().width(150)
},function(){
$(this).width(200);
})
})
</script>
</body>
</html>
jquery实现手风琴效果
最新推荐文章于 2025-06-03 09:11:21 发布