我正在尝试制作一个外观漂亮的底部抽屉滑块。
页面底部将固定一个圆形按钮,当抽屉关闭时只显示一半(半圆形),点击它可以展开抽屉。
简单的示意图如下:
_____________________________
| Web Page |
| |
| |
| ____ |
|__________/ /\ \___________| < Closed (bottom of browser window)
_____________________________
| Web Page |
| ____ |
|__________/ /\ \___________| < Opened
| \____/ |
|___________________________|
JsFiddle: https://jsfiddle.net/ppgab/wcec9gc6/4/(我正在使用Semantic UI,但这不是必需的)
当抽屉关闭时,如何让按钮只显示一半?
HTML
<div>Page content</div>
<div id="map" class="down">
<div>
<i class="ui circular link expand big inverted icon"></i>
</div>
bottom slider content
</div>
CSS
#map {
background-color: #303030;
width: 100%;
text-align: center !important;
height: 4%;
bottom: 0;
position: fixed;
}
JavaScript/jQuery
$('.icon').click(function() {
if ($("#map").hasClass("down")) {
$("#map").removeClass("down");
$("#map").animate({
height: "50%"
}, 600);
} else {
$("#map").animate({
height: "4%"
}, 350);
$("#map").addClass("down");
}
});
如果使用百分比尺寸会更好。