jQuery의 아코디언과 같은 효과를 만들어야합니다. 나는 스크린을 채우는 10 가지 항목을 가지고있다. 마우스를 항목 위로 가져 가면 너비가 확장됩니다. 마지막 5 개 항목을 오른쪽에서 왼쪽으로 확장하는 방법은 무엇입니까?CSS의 오른쪽에서 왼쪽으로 펼치기
내 HTML :
<div class="wrap">
<div style="width: 165.25px; background: rgb(228, 228, 230);" class="item"></div>
<div style="width: 165.25px; background: rgb(35, 123, 192);" class="item"></div>
<div style="width: 165.25px; background: rgb(20, 4, 4);" class="item"></div>
<div style="width: 165.25px; background: rgb(182, 159, 36);" class="item"></div>
<div style="width: 165.25px; background: rgb(162, 169, 180);" class="item"></div>
<div style="width: 161px; background: rgb(37, 29, 4);" class="item"></div>
<div style="width: 161px; background: red;" class="item"></div>
<div style="width: 161px; background: rgb(88, 45, 45);" class="item"></div>
<div style="width: 161px; background: rgb(202, 41, 176);" class="item"></div>
<div style="width: 161px; background: rgb(24, 207, 185);" class="item"></div>
</div>
이 내 CSS입니다 :
.wrap{
width:100%;
float:left;
height: 300px;
overflow: hidden;
}
.item {
float:left;
height: 100%;
display: block;
}
jQuery 코드 :
$('.item').each(function(e){
$(this).css('width', ($(this).parent().width()/10));
});
$('.item').on('mouseenter', function(event) {
$(this).stop().animate({width: "50%"}, {duration: 500});
}).on('mouseleave', function(event) {
$(this).stop().animate({width: ($(this).parent().width()/10)}, {duration: 500});
});
감사합니다.