简体   繁体   English

主要内容下的麻烦定位页脚

[英]Trouble positioning footer under main content

I'm trying to create my website from scratch, and facing quite a few problems along the way.. The most recent problem being that I can't manage to get my footer positioned after the main-wrapper div. 我正在尝试从头开始创建我的网站,并且在此过程中面临许多问题。.最近的问题是我无法设法使页脚位于main-wrapper div之后。 The most obvious reason why I'm encountering this problem is because main-wrapper contains elements which are absolutely positioned and so its height doesn't adjust accordingly. 我遇到此问题的最明显原因是main-wrapper包含绝对定位的元素,因此其高度不会相应地调整。 I searched all over the place before asking and I even implemented a clearfix to no result.. 在询问之前,我到处搜索,甚至实施了一个clearfix,但没有结果。

The page is here 页面在这里

I also created a Plunk with all the files here 我还用这里的所有文件创建了一个Plunk

what about adding this to your css #footer: 如何将此添加到您的CSS #footer:

 position: absolute;
 width: 100%;
 bottom: 0;

( if you want the footer to get pushed down the page if there is more content in content, this want work ) (如果您希望页脚在内容中包含更多内容时被下推,则此方法可以解决)

Try this to your footer css style, 尝试此为您的页脚CSS样式,

#globalfooter{
   position:absolute;
   bottom:0px; 
}

I think using css it will be very difficult, you can try using this script 我认为使用CSS会非常困难,您可以尝试使用此脚本

 <script type="text/javascript">
    document.getElementsByClassName('main-wrapper')[0].style.height = document.getElementsByClassName('hero-bg')[0].offsetHeight+"px";
 </script>

put this just below of closing of "main-wrapper" section 将其放在“主包装”部分关闭的下方

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM