简体   繁体   English

引导行中的html的背景图像

[英]Reapet background image of html in bootstrap row

I have a very simple page in HTML and I added a background image using the code that I found here . 我有一个非常简单的HTML页面,并使用在这里找到的代码添加了背景图片。

html { 
  background: url(images/bg.jpg) no-repeat center center fixed; 
  -webkit-background-size: cover;
  -moz-background-size: cover;
  -o-background-size: cover;
  background-size: cover;
}

Now I'm trying to add my bootstrap rows and my page is all blank, because the background colour of the row. 现在,我正在尝试添加引导程序行,并且我的页面全部为空白,因为该行的背景色。 I can change it with background-color , but I can't make it repeat the background image. 我可以使用background-color更改它,但不能使其重复背景图像。

This is my html: 这是我的html:

<div class="wrapper" role="main">
            <div class="container-fluid">
                <div class="row">
                    <header id="header" class="col-md-12">
                        <h1>System Name</h1>
                    </header>
                </div>
                <div class="row">
                    <section class="col-md-4 col-md-offset-4">
                        <img class="img-responsive center-block" src="images/logo.jpg"/>
                        <form class="col-md-8 col-md-offset-2" role="form" action="login.php" method="POST">
                            <div class="form-group">
                                <label for="login">Login:</label>
                                <input id="login" class="form-control" type="text"/>
                            </div>
                            <div class="form-group">
                                <label for="password">Pass:</label>
                                <input id="password" class="form-control" type="password"/>
                            </div>
                            <div class="checkbox">
                                <label><input type="checkbox">Remember</label>
                            </div>
                            <input class="btn btn-success" type="submit" value="Log In"/>
                        </form>
                    </section>
                </div>
            </div>
       </div>

How can I set it with the the same background image? 如何设置相同的背景图像? I tried background-color:transparent , but it didn't work 我尝试了background-color:transparent ,但是没有用

I managed to fix this by changing the CSS to 我设法通过将CSS更改为

html, body { 
  background: url('http://www.lawofattraction4u.org/wp-content/uploads/2015/06/photodune-2102679-planet-earth-l.jpg') no-repeat center center fixed; 
  -webkit-background-size: cover;
  -moz-background-size: cover;
  -o-background-size: cover;
  background-size: cover;
}

Example pen here . 示例笔在这里

This is happening because you only had HTML listed in the selector, however the body is actually what you're wanting to cover. 发生这种情况是因为选择器中仅列出了HTML,但是主体实际上是您要覆盖的内容。

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

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