Jac*_*per 2 css jquery footer ipad
我正在努力修复我的网站在 iPad 纵向模式下的显示。问题是页面长度没有 iPad 的纵向显示那么长。这是我正在谈论的内容的图片:

我创建了一个 jQuery 函数,我认为该函数可以检测文档高度是否与窗口高度一样大,然后我可以将页脚的位置设置为固定。这是我的代码:
if ($(document).height() < $(window).height()) {
$('#footer-wrapper').attr('style', 'position: fixed!important; bottom: 0px;');
}
Run Code Online (Sandbox Code Playgroud)
当前CSS:
#footer-wrapper {
padding: 20px 0px 23px;
background-color: #E3E9DC;
border-bottom: 3px solid #007897;
border-top: 3px solid #007897;
color: #585858;
position: absolute;
bottom: 0px;
left: 0px;
width: 100%;
text-align: center;
}
@media screen and (max-width: 1024px) {
#footer-wrapper {
/*padding: 20px 0px 23px;*/
background-color: #E3E9DC;
border-bottom: 3px solid #007897;
border-top: 3px solid #007897;
color: #585858;
position: relative;
margin-bottom: -65px!important;
width: 100%;
text-align: center;
}
}
Run Code Online (Sandbox Code Playgroud)
我认为这可行,但由于某种原因,文档说它的高度大于窗口视口,因此不执行 if 语句。有谁知道实现这一目标的更可靠的方法?
只需将 javascript 更改为:
if ($(document.body).height() < $(window).height()) {
$('#footer-wrapper').attr('style', 'position: fixed!important; bottom: 0px;');
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3906 次 |
| 最近记录: |