這裏是整個代碼:
<style type="text/css">
.wrapper{
max-width:613px;
float:left;
position:relative;
}
.new {
border: solid 1px #ddd;
padding: 5px;
float:left;
max-width:660;
min-width:320px;
}
.item{
width:120px;
padding:10px;
display:block;
background-color:#CCC;
float:left;
margin:5px;
}
.content{
padding:10px;
height:80px;
visibility:hidden;
}
.item:hover > .content{
}
.full{
position:absolute;
width:100%;
display:block;
height:100px;
background-color:#666;
left:0px;
}
</style>
<script type='text/javascript'>//<![CDATA[
window.addEvent('load', function() {
(function(){
var wrap,
overview = document.getElement('div.overview');
overview.getElements('div.item').each(function(a, i){
if (i % 4 == 0){
wrap && overview.adopt(wrap);
wrap = new Element('div.new');
}
wrap.adopt(a);
});
overview.adopt(wrap);
}());
});
window.addEvent('domready', function() {
$$('.item').each(function(el,ind){
new Fx.Slide($$('.content')[ind]).toggle();
el.addEvent('click', function(event){
event.stop();
var myVerticalSlide = new Fx.Slide($$('.content')[ind]).toggle();
});
})
});//]]>
</script>
</head>
<body>
<div class="wrapper">
<div class="overview">
<div class="item">Test1
<div class="content">
<div class="full">
<p>Content1</p>
</div>
</div>
</div>
<div class="item">Test2
<div class="content">
<div class="full">
<p>Content2</p>
</div>
</div></div>
<div class="item">Test3
<div class="content">
<div class="full">
<p>Content3</p>
</div>
</div></div>
<div class="item">Test4
<div class="content">
<div class="full">
<p>Content4</p>
</div>
</div></div>
<div class="item">Test5
<div class="content">
<div class="full">
<p>Content5</p>
</div>
</div></div>
<div class="item">Test6
<div class="content">
<div class="full">
<p>Content6</p>
</div>
</div></div>
<div class="item">Test7
<div class="content">
<div class="full">
<p>Content7</p>
</div>
</div></div>
<div class="item">Test8
<div class="content">
<div class="full">
<p>Content8</p>
</div>
</div></div>
<div class="item">Test9
<div class="content">
<div class="full">
<p>Content9</p>
</div>
</div></div>
<div class="item">Test10
<div class="content">
<div class="full">
<p>Content10</p>
</div>
</div></div>
<div class="item">Test11
<div class="content">
<div class="full">
<p>Content11</p>
</div>
</div></div>
</div>
</div>
的另一件事是,當我在德第一個div點擊,打開它,在這之後,當我點擊第二個div它也打開,但第一個div應該關閉,當我點擊第二個div時。
謝謝,我該如何改變狀態?這就是它的全部關閉,當我點擊,它打開? – fr3d 2013-03-07 16:10:51
我已經添加了一行'new Fx.Slide($$('。content')[ind])。hide();' ,試一試吧 – wearwoolf 2013-03-07 16:14:10
看起來不錯,但是當我刷新頁面時,div是短時間打開的,並且比它們關閉 – fr3d 2013-03-07 16:17:22