我正在嘗試爲以象限格式佈置的某些html元素創建動畫。點擊每個div後,我希望它們擴展到容器高度和寬度的100%,然後再次單擊摺疊回初始大小。這與瀏覽器的動畫類似,最大化並摺疊回原始大小。Css/jQuery動畫用於將div擴展爲屏幕的100%
我現在擁有的工作正常,我只想讓動畫不會將其他元素從屏幕上移開,也不會在標題消失時跳轉。
我該怎麼做?隨意使用jQuery動畫或css3動畫。謝謝!
這裏是什麼,我現在有一個演示:JSFIDDLE 的Javascript
$(document).ready(function() {
$('.box1').on('click', function() {
$(this).animate({height: "100%", width: "100%"}, 500);
});
});
HTML
<div id="page-wrapper">
<div class="header"></div>
<div class="box-container clearfix">
<div class="box1"></div>
<div class="box2"></div>
<div class="box3"></div>
<div class="box4"></div>
</div>
</div>
CSS
#page-wrapper {
width: 400px;
height: 480px;
border: 1px solid lightblue;
}
.box-container {
width: 100%;
height: 100%;
}
.header {
background: black;
height: 40px;
width: 100%;
}
.box1{
background: yellow;
height: 190px;
width: 170px;
margin: 10px;
float: left;
}
.box2 {
background: red;
height: 190px;
width: 180px;
margin: 10px;
float: right;
}
.box3 {
background: green;
height: 190px;
width: 170px;
margin: 10px;
float: left;
}
.box4 {
background: blue;
height: 190px;
width: 180px;
float: right;
margin: 10px;
}
這很好!唯一的事情是綠框似乎跳出框架,並且我還希望如果標題消失或重疊.. – Chrisgozd
給我一些時間來處理它。 :) –
謝謝,我真的很感激它。 – Chrisgozd