Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/364.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 使用css或jquery的粘性页脚_Javascript_Jquery_Css - Fatal编程技术网

Javascript 使用css或jquery的粘性页脚

Javascript 使用css或jquery的粘性页脚,javascript,jquery,css,Javascript,Jquery,Css,如何将div设置为即使在滚动时也保持在浏览器屏幕底部?假设您有以下div 这在底部 您可以使用以下CSS使其粘贴在视口的底部 .footer { position: fixed; bottom: 0; } 即使在滚动时,它也会留在那里。尝试一下以下CSS: * { margin: 0; } html, body { height: 100%; } .wrapper { min-height: 100%; height: auto !important;

如何将div设置为即使在滚动时也保持在浏览器屏幕底部?

假设您有以下div

这在底部

您可以使用以下CSS使其粘贴在视口的底部

.footer {
  position: fixed;
  bottom: 0;
}

即使在滚动时,它也会留在那里。

尝试一下以下CSS:

* {
    margin: 0;
}
html, body {
    height: 100%;
}
.wrapper {
    min-height: 100%;
    height: auto !important;
    height: 100%;
    margin: 0 auto -142px; /* the bottom margin is the negative value of the footer's height */
}
.footer, .push {
    height: 142px; /* .push must be the same height as .footer */
}

CSS源代码:

粘性页脚的实现

请看一看


使用
position:fixed
附加到该
div的CSS属性

#footer {
    position:fixed;
    bottom:0;
}

这里有一个优秀的页脚教程

演示页面如下:

基本前提是主体页面被拉伸到页面的100%。最小高度也为100%

然后为页脚提供以下规则:

#footer {
 clear: both;
 position: relative;
 z-index: 10;
 height: 3em;
 margin-top: -3em;
}

我从

@Pranav得到了答案。我看到了你的谷歌搜索,并向你提出了一个网站搜索:759个问题。重复的重复。可能的重复,以及与之相关的几十个问题。可能的重复