【发布时间】:2017-03-06 06:12:08
【问题描述】:
我有一个很好的下拉页脚:
$('#drop-up-open').click(function() {
$('#drop-up #drop-upDashboard').slideToggle({
direction: "up"
}, 300);
$(this).toggleClass('drop-upClose');
}); // end click
#drop-up {
position: absolute;
bottom: 0;
width: 100%;
padding-bottom: 4%;
z-index: 100;
margin-left: auto;
margin-right: auto;
left: 0;
right: 0;
}
#drop-up-open {
cursor: pointer;
text-decoration: none;
}
#drop-up .drop-upClose {}
#drop-up #drop-upDashboard {
display: none;
}
@media screen and (max-width: 1000px) {
#drop-up #drop-upDashboard{
display:block; }
}
<div class="container">
<!-- Jumbotron Header -->
<header class="jumbotron panel-heading">
<p class="text-center">
Text getting covered by drop-up menu on mobile
</p>
<section>
<a href="#"><button> Main button </button></a>
</section>
</header>
<div id="drop-up">
<a href="#" id="drop-up-open">Open</a>
<div id="drop-upDashboard">
<p>It's now open!</p>
<div class="row">
<div class="col-md-3 col-xs-12">
<section> <a href="#"><button>
<p>Button 1</p>
</button></a> </section>
</div>
<div class="col-md-3 col-xs-12">
<section> <a href="#"><button>
<p>Button 2</p>
</button></a> </section>
</div>
<div class="col-md-3 col-xs-12">
<section> <a href="#"><button>
<p>Button 3</p>
</button></a> </section>
</div>
<div class="col-md-3 col-xs-12">
<section> <a href="#"><button>
<p>Button 4</p>
</button></a> </section>
</div>
</div>
<!-- row -->
</div>
<!-- dashboard -->
</div>
<!-- drop-up -->
</div>
<!-- container -->
当我单击 id="drop-up" div 时,菜单从下到上打开,并在桌面视图中占据窗口底部的一小部分。
现在,我想要的是这个最初隐藏在桌面视图中的菜单,在较小的设备(移动设备+平板电脑)上显示,而无需单击 id="drop-up" div。它将占据移动设备+平板电脑页面底部的相同部分(然后用户需要向下滚动才能在较小的设备上查看下拉菜单,而在桌面视图中则不然)。
关于实现这一目标的最佳方法的任何建议/提示?
【问题讨论】:
-
这很容易通过
@media查询来实现。网上应该有很多例子 -
谢谢。我刚刚编辑了 CSS 部分。但是,我有一个尺寸问题,因为按钮在移动设备上相互堆叠,并且它们不会像应有的那样在页面底部受到限制,而是超出了它们的预期限制并显示在上面的内容之上。这有什么线索吗?
-
不确定您的意思,它们不应该堆叠吗?对我来说看起来不错,也许可以多编辑一下你的 sn-p 以显示它上面的“内容”或 w/e
-
我在上面有一个简单的标题作为编辑。事实上,这些按钮应该在移动设备上堆叠,但它们不应该显示在标题顶部。我一定是搞错了。
-
是的,这是因为
position absolute定位绝对函数类似于fixed,但允许相对于display relative元素而不是窗口定位
标签: javascript jquery html css