手风琴
效果图
具体代码如下
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<style type="text/css">
*{
margin: 0;
padding: 0;
}
#oul{
list-style: none;
width: 1000px;
height: 600px;
border: 1px solid red;
margin: 300px auto;
}
li{
width: 198px;
height: 598px;
border: 1px solid yellow;
float: left;
overflow: hidden;
transition: 1s;
}
</style>
</head>
<body>
<ul id="oul">
<li><img src="images/1.jpg"/></li>
<li><img src="images/2.jpg"/></li>
<li><img src="images/3.jpg"/></li>
<li><img src="images/4.jpg"/></li>
<li><img src="images/5.jpg"/></li>
</ul>
</body>
<script type="text/javascript">
var olist=document.getElementById('oul');
var oli=olist.getElementsByTagName('li');
for(var i=0; i<oli.length; i++){
oli[i].index=i;
oli[i].onmouseover=function(){
for(var j=0; j<oli.length; j++){
oli[j].style.width=98+'px';
}
oli[this.index].style.width=598+'px';
}
}
olist.onmouseout=function(){
for(var j=0; j<oli.length; j++){
oli[j].style.width=198+'px';
}
}
</script>
</html>
转载请注明原文地址:https://blackberry.8miu.com/read-1112.html