我在页面中央有一个圆形的div,我希望当点击它时,它能够扩展到整个屏幕的大小。有什么建议吗?
如果可能的话,我希望它能够平滑地过渡。
如果可能的话,我希望它能够平滑地过渡。
div.small {
background: #f00;
border-radius: 50%;
width: 100px;
height: 100px;
position: absolute;
top: 50%;
left: 50%;
margin-left: -50px;
margin-top: -50px;
transition: all .5s;
}
div.big {
width: 100%;
height: 100%;
top: 0;
margin-top: 0;
left: 0;
margin-left: 0;
border-radius: 0;
background: #0f0;
}
JS(我正在使用Zepto,但jQuery同样适用)
$(window).on("click", ".small", function() {
me = this;
setTimeout( function() { $(me).addClass("big"); }, 1 );
});
$(window).on("click", ".big", function() {
me = this;
setTimeout( function() { $(me).removeClass("big"); }, 1 );
});
HTML
<div class="small"></div>
CSS
http://jsfiddle.net/frapporti/Vc492/
label {
background: #f00;
border-radius: 50%;
width: 100px;
height: 100px;
position: absolute;
top: 50%;
left: 50%;
margin-left: -50px;
margin-top: -50px;
transition: all .5s;
}
input:checked + label {
width: 100%;
height: 100%;
top: 0;
margin-top: 0;
left: 0;
margin-left: 0;
border-radius: 0;
background: #0f0;
}
input {
visibility: hidden;
position: absolute;
}
HTML
<input id="hidden-checkbox" type="checkbox"></input>
<label for="hidden-checkbox"></label>