,可以嘗試通過CSS
加入一些transition
動畫如下,並添加/刪除類說small
這裏定義小width
和left
性能:
.child-element {
width: 90%;
overflow: auto;
margin: auto;
position: absolute;
top: 0px;
left: 0;
bottom: 0;
right: 0;
-webkit-transition: all 1s ease-in-out;
-moz-transition: all 1s ease-in-out;
-o-transition: all 1s ease-in-out;
transition: all 1s ease-in-out;
}
.small {
left: 20px;
width: 80%;
}
個
JS
$('#makesmall').on('click', function() {
$('.child-element').addClass('small');
});
$('#makebig').on('click', function() {
$('.child-element').removeClass('small');
});
UPDATED FIDDLE
我需要將它添加到我的孩子元素類或我需要建立一個新的類? –