部分背景溢出到另一部分

时间:2016-11-16 06:59:14

标签: html css twitter-bootstrap-3 responsive-design

我提前为这个有点冗长的解释道歉。我正在尝试创建一个像http://melaniedaveid.com/这样的网站来提高我的编码能力。我创建了第一个部分页面,结果很棒。但是当我添加另一部分时,上一部分不再填满整个页面(图片:http://imgur.com/a/EbUKn)。

为了解决这个问题,我给了第一部分ID:

#header {
height: 100%;}

这解决了问题(http://imgur.com/a/BlckC),但现在当我调整浏览器大小时,第二部分会流入我的第一部分,覆盖文本(http://imgur.com/a/C1jED)。任何建议/线索将不胜感激!

body {
  background: linear-gradient(rgba(0, 0, 0, 0.7), rgba(0, 0, 0, 0.7)), url('/img/roses.jpg') no-repeat center center fixed; 
  -webkit-background-size: cover;
  -moz-background-size: cover;
  -o-background-size: cover;
  background-size: cover;
  font-size: 20px;
  height: 100vh;
}

/*------------------------------------------------  HOME PAGE  ------------------------------------------------------------------*/

/*------------------------------
HEADING TEXT
-------------------------------*/
.name h1 {
  font-family: 'Muli', sans-serif;
  font-size: 500%;
  font-weight: 300;
  text-align: center;
  padding-top: 10%;
  color: #ecf0f1;
  font-family: 'Cormorant Garamond', serif;
}

.name p {
  font-family: 'Play', sans-serif;
  font-size: 130%;
  text-align: center;
  padding-top: 5%;
  color: #ecf0f1;
  font-family: 'Merriweather', serif;
  font-weight: 300;
  padding-right: 10%;
  padding-left: 10%;
}

/*------------------------------
Nav Bar
-------------------------------*/

.navigation p {
  display: inline;
  font-family: 'Play', sans-serif;
  color: #ecf0f1;
}

.navigation {
  text-align: center;
  padding-top: 15%;
}

.contents,
.contents:hover {
  text-decoration: none;
  color: #ecf0f1;
  font-family: 'Delius Unicase', cursive;
}

/*------------------------------------------------  ABOUT PAGE  ------------------------------------------------------------------*/

/*------------------------------
About Heading
-------------------------------*/

#about {
  background-color: black;
  background-size: cover;
  height: 100%;

}

#header {
  height: 100%;
}
<section id="header">  <!-------------------------  HOME PAGE  -------------------------->


  <div class="container">
    <div class="row">
      <div class="col-xs-12 name">
        <h1>Temple Naylor</h1>
      </div>
    </div>

    <div class="row">
      <div class="col-xs-12 name">
        <p>I create Web-designs with a sense of Feng-Shui in mind; resulting for a intuitive, responsive, harmonious, experience for users across the world.</p>
      </div>
    </div>

    <div class="row">
      <div class="col-xs-12 navigation hidden-sm-down">
        <p><a class="contents" href="#">ABOUT</a> / </p>
        <p><a class="contents" href="#">WORK</a> / </p>
        <p><a class="contents" href="#">CONTACT</a> / </p>
        <p><a class="contents" href="#">PHOTOGRAPHY</a></p>

      </div>
    </div>
  </div>

</section>


<section id="about">  <!-------------------------  ABOUT PAGE  -------------------------->


  <div class="container">
    <div class="row about">
      <div class="col-md-6">
        <p class="big-text"></p>
      </div>
    </div>

    <div class="row">
      <div class="col-md-6 about-text">
        <p >Yup</p>
      </div>
    </div>
  </div>
</section> 

2 个答案:

答案 0 :(得分:1)

您可以使用css vh属性。

#header {
    height: 100vh;
}

这里有关于css units的更多信息。希望这会对你有所帮助。

答案 1 :(得分:0)

将#header height更改为min-height:

#header { 
    min-height: 100%; 
}