【发布时间】:2016-04-06 07:54:32
【问题描述】:
我有一个网格,里面有绝对定位的框。这些盒子有一个头部和一个隐藏的页面部分......当我点击一个按钮时,所有的盒子都将被隐藏,所选的盒子变成 100% 宽,它的隐藏页面向下滑动显示。 我的问题是我的网站在网格下方的部分(我的页脚)被向下滑动的页面隐藏了,因为网格的高度不会压低网站的下部... 我无法为网格提供固定高度,因为不同的内容会有所不同...我不明白为什么系统不计算我的相对定位网格的高度...
HTML 结构:
<div class="container">
<div class="header">
<button class="showclick">Show</button>
<button class="hideclick">Hide</button>
</div>
<div class="grid">
<div class="box">
<div class="box-head"></div>
<div class="page"></div>
</div>
</div>
<div class="footer">This is my footer which should be under the slide-downed (shown) page</div>
</div>
我想问题出在我的 CSS 上。但是由于系统复杂,我不确定我可以在其中更改定位和溢出...
body {position:relative;display:block;max-width:800px;min-height:101vh; margin:0 auto;overflow-x:hidden}
.content {position:relative;display:block;width:100%;padding:5%;background:blue}
.header {position:relative;display:block;width:100%;background:orange}
.showclick, .hideclick {position:relative;width:20%;height:30px}
.grid {position:relative;display:block;min-height:500px;background:grey}
.grid:after {content:'';display:block;clear:both}
.box {position:absolute;left:0;top:0;width:100%;height:200px;color:#fff;background:#a2c5bf}
.box-head {position:relative;display:block;width:100%;height:200px;background:red;overflow:hidden}
.page {position:relative;width:100%;height:auto;padding:5%;background:yellow}
.footer {position:relative;display:block;width:100%;text-align:center;background:green}
是否可以通过单击按钮使用 jquery 计算网格(或页面)高度?
【问题讨论】:
标签: jquery css height css-position slidedown