简体   繁体   English

100%最小高度包装破坏背景

[英]100% min-height wrapper breaks background

I have a repeating background on a wrapper that provides the background for the nav-bar. 我在包装器上有重复的背景,为导航栏提供背景。 It should extend all the way down the page. 它应该一直延伸到页面下方。 I had hoped to accomplish this just by setting the min-height of the wrapper to 100%. 我希望通过将包装器的最小高度设置为100%来实现这一目标。 When I do this, the background disappears. 当我这样做时,背景消失了。 Does anyone know why? 有谁知道为什么?

Here's the site: https://hodkiewicz-zieme-and-hirthe180.myshopify.com/ 这是网站: https//hodkiewicz-zieme-and-hirthe180.myshopify.com/

Here's the relevant CSS: 这是相关的CSS:

.wrapper {
    width: 940px;
    min-height: 100%;
    margin: 0 auto;
    text-align: left;
    background-image: url({{'body-bg.png' | asset_url}});
    background-repeat: repeat-y;
}

Anytime you float elements the parent element usually collapses you need use a clearfix hack to fix that 无论何时浮动元素,父元素通常会崩溃,您需要使用clearfix hack来修复它

http://css-tricks.com/snippets/css/clear-fix/ has a good one copy the class into your style sheet and use it next to your wrapper class like class="wrapper clearfix" http://css-tricks.com/snippets/css/clear-fix/有一个很好的方法将类复制到你的样式表中并在你的包装类旁边使用它,如class="wrapper clearfix"

This float is making the wrapper collapse #navbar {float:left} 这个浮动使包装器崩溃#navbar {float:left}

Add below the div class="content" the following htm/css: 在div class =“content”下面添加以下htm / css:

HTML: HTML:

<div class="content">...</div>
<div class="clear-fix"></div>

CSS: CSS:

.clear-fix {
    clear: both;
}

Hi you have used floating in your child elements not clear your parent wrapper div so that's why the problem is coming so clear your parent wrapper div with overflow:hidden; 嗨,你已经使用floating你的child elements clear你的父wrapper div ,这就是为什么问题来得如此clear你的父wrapper divoverflow:hidden; problem will sort out. 问题将解决。

UPDATE YOUR CSS WITH MENTIONED BELOW CSS 使用CSS提示更新CSS

CSS CSS

.wrapper {
    background-image: url("http://static.shopify.com/s/files/1/0098/1262/t/107/assets/body-bg.png?2789");
    background-repeat: repeat-y;
    margin: 0 auto;
    min-height: 100%;
    overflow: hidden;
    text-align: left;
    width: 940px;
}

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

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