我似乎无法弄清楚如何从下往上显示隐藏的内容,而不是从上到下。我在这里完成了一些功课,并遇到了来自jQuery UI的解决方案,但必须实现它错误。非常感谢任何帮助 - 脚本新手。
喝彩!
这是我正在使用的
脚本:
$(document).ready(function() {
$('#clientsOpen').click(function() {
$('#clientsDropDown #clientsDashboard').slideToggle({ direction: "up" }, 300);
$(this).toggleClass('clientsClose');
}); // end click
});
标记:
<div id="clientsDropDown">
<div id="clientsDashboard">
<p id="clientsCTA">Let's make something beautiful together...<br /><a href="mailto:brockman.eric@gmail.com">brockman.eric@gmail.com</a></p>
</div><!-- /clientsDashboard -->
<p id="clientsOpen">clients</p>
</div><!-- //clientsDropDown -->
风格:
#clientsDropDown {
bottom:0;
width: 100%;
padding-bottom:2%;
z-index: 100;
}
#clientsOpen {
background: url("images/open.png") no-repeat scroll 68px 10px #414142;
color: #ececec;
cursor: pointer;
float: left;
font-size: 26px;
margin: -2px 0 0 10%;
padding: 0 15px 2px;
text-decoration: none;
width: 63px;
}
#clientsCTA {
background:#414142;
width:100%;
color: #CCCCCC;
text-align:center;
font-size: 46px;
margin: 0;
padding: 30px 0;
text-decoration: none;
}
#clientsDropDown .clientsClose {
background-image: url(images/close.png);
}
#clientsDropDown #clientsDashboard {
display: none;
}
答案 0 :(得分:11)
只需将position:absolute;
添加到#clientsDropDown
。
<强> jsFiddle example 强>
或者,如果您希望“客户”位于弹出式窗口顶部,请移除浮动并将段落放置在仪表板div上方,如 jsFiddle example 中所示。
答案 1 :(得分:1)
尝试将脚本更改为:
$("#clientsOpen").click(function(){
$("#clientsDashboard").slideToggle();
}, function(){
$("#clientsDashboard").slideToggle();
});
是的,当然将容器div定位为绝对值。
答案 2 :(得分:0)
改变揭示动画方向的实际属性是bottom
CSS属性。如果它被更改为top
,动画将显示向下而不是向上。
在前面提供的小提琴中为#clientsDropDown
试一试,你会看到它在行动。