简体   繁体   English

Bootstrap:100%高度的页脚

[英]Bootstrap: 100% height footer

I have an issue with the height of my footer. 我的页脚高度有问题。

On the mobile website the footer is as I expect but when I take a look on desktop the background color gone. 在移动网站上,页脚就像我期望的那样,但是当我在桌面上看一看时,背景颜色就消失了。

在移动

And this is what I see on my desktop: 这就是我在桌面上看到的内容: 这就是我在桌面上看到的内容:

Here is my code: 这是我的代码:

  footer { background-color: #232323; height: 100%; border-top: #ebe050 5px solid; } footer .widget-title { color: #ebe050; } footer .widget-content { color: #eaeaea; } 
  <div class="row"> <footer> <div class="col-md-4"> <div class="widget-title"> <h3>About us</h3> </div> <div class="widget-content"> <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean elementum lacus in lacus dictum, vitae pulvinar sem tempor. Nulla rutrum, lectus eget pulvinar egestas, quam lacus luctus ante, eget facilisis magna leo ut ipsum. Aenean tempus lorem arcu, id dapibus elit aliquet et.</p> </div> </div> <div class="col-md-4"> <div class="widget-title"> <h3>About us</h3> </div> <div class="widget-content"> <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean elementum lacus in lacus dictum, vitae pulvinar sem tempor. Nulla rutrum, lectus eget pulvinar egestas, quam lacus luctus ante, eget facilisis magna leo ut ipsum. Aenean tempus lorem arcu, id dapibus elit aliquet et.</p> </div> </div> <div class="col-md-4"> <div class="widget-title"> <h3>Categories</h3> </div> <div class="widget-content"> <ul> <li>Girl vs Girl</li> <li>MMA</li> <li>WWE</li> <li>Street</li> <li>Sparring</li> </ul> </div> </div> </footer> </div> 

Thank you very much for your help! 非常感谢您的帮助!

Few things. 一些事情。

You could remove footer from footer .widget-*whatever* scene as the browser will just select anything with the class .widget-*whatever* - but it's totally up to you. 你可以从footer .widget-*whatever*删除footer ,因为浏览器只会选择类.widget-*whatever* ,但这完全取决于你。

Second thing, what you could do is change height to min-height but please make sure that the container the footer is in has a SET HEIGHT otherwise having a percentage for your height will be pointless (because how can the browser take a percentage of nothing?). 第二件事,你可以做的是将height改为min-height但请确保页脚所在的容器有一个SET HEIGHT,否则你的身高百分比将是毫无意义的(因为浏览器怎样才能占用一定比例的百分比) ?)。 Having min-height , this will force the element to be at least 100% - meaning if you don't fill the full space, you'll have blank space at the bottom but if you use max-height , it will be the set height given or less, meaning everything looks normal, if it fits in the given space. min-height ,这将强制元素至少100% - 这意味着如果你没有填满整个空间,你将在底部有空白,但如果你使用max-height ,它将是集合高度给定或更少,意味着一切看起来正常,如果它适合给定的空间。

Hopefully, this answer sorts your problem. 希望这个答案可以解决你的问题。

CSS for you. CSS为你服务。

footer {
    background-color: #232323;
    min-height: 100%; /*Make sure the container for the footer has a set height*/
    border-top: #ebe050 5px solid;
}
.widget-title {
    color: #ebe050;
}
.widget-content {
    color: #eaeaea;
}

You may want to try max-height and min-height and see what one works best for you. 您可能需要尝试max-heightmin-height ,看看哪种方式最适合您。

Put the div class="row" inside the footer Tag, so the footer should contain the rows and cols. 将div class =“row”放在页脚标记内,因此页脚应包含行和列。

UPDATE: Working example: http://www.bootply.com/render/ZnruhjLe8C 更新:工作示例: http//www.bootply.com/render/ZnruhjLe8C

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

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