如何使图片适合带有导航的页面

How to make a picture fit on the page with navigation

所以我想做的是让我的图像适合页面而不需要滚动。很明显,超大屏幕和导航正在将图像向下推,所以对我来说有意义的是将图像放在超大屏幕和导航的后面。我尝试了隐藏的溢出,但似乎没有用。我还尝试将所有内容放入我的包装器中,这很有效,但后来我的响应式设计全都搞砸了。这是将覆盖页面的图片:[https://static.pexels.com/photos/7106/macbook-computer-clean-hero.jpg][1]

这是我的代码:

html, body {
margin: 0;
padding: 0;
display: table;
width: 100%;
height: 100%;
}
.jumbotron {
background-color: rgba(51, 51, 51, 1);
padding-bottom: 0;
margin-top: -20px;
margin-bottom: 0;
padding-top: 20px;
h1 {
font-size: 5em;
text-transform: uppercase;
font-weight: 100;
color: #fff;
margin: .2em 0 0 .2em;
letter-spacing: .2em;
span {
font-weight: normal;
}
}
p {
color: #fff;
margin-right: .5em;
margin-bottom: 0;
}
#slogan {
font-size: 1.2em;
margin: 0;
margin-right: 20px;
}
}
.navbar {
background-color: rgba(51, 51, 51, 1);
border-radius: 0;
margin-top: 0;
margin-bottom: 0;
min-height: 0;
border: none;
li a {
outline: none;
text-transform: uppercase;
padding: 5px 15px 10px 15px;
font-size: .9em;
}
}
.wrapper{ // The wrapper is ONLY on the index.html page.
// position: relative;
display: table;
width: 100%;
height: 100%;
text-align: center;
color: #FFF;
background-image: url("https://static.pexels.com/photos/7106/macbook-computer-clean-hero.jpg");
background-position: center center;
background-size: cover;
}
.h2_slogan {
font-weight: 100;
font-size: 3em;
text-transform: uppercase;
margin-top: 1em;
}
<header class="jumbotron">
   <h1>John <span>Smith</span></h1>
   <p class="text-right" id="slogan">Accessible. Affordable. Dependable.</p>
</header>
<nav class="navbar navbar-inverse">
   <div class="container-fluid">
      <!-- Brand and toggle get grouped for better mobile display -->
      <div class="navbar-header">
         <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
         <span class="sr-only">Toggle navigation</span>
         <span class="icon-bar"></span>
         <span class="icon-bar"></span>
         <span class="icon-bar"></span>
         </button>
      </div>
      <!-- Collect the nav links, forms, and other content for toggling -->
      <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
         <ul class="nav navbar-nav text-center">
            <li><a href="index.html">Home</a></li>
            <li><a href="about.html">About</a></li>
            <li><a href="#">Skills</a></li>
            <li><a href="#">Portfolio</a></li>
            <li><a href="contact.html">Contact</a></li>
         </ul>
      </div>
   </div>
</nav>
<div class="wrapper">
   <h2 class="text-center h2_slogan">Web Developer & Designer</h2>
</div>

您可以将它添加到您的 body 这将把它放在 jumbotronnavbar 之后。

你的工作:

HTML

中更改此设置

发件人:

<body>

收件人:

<body id="homepage">


将此添加到您的 CSS:

body {
    background-image: url("../img/header.jpg");
    background-position: center center;
    background-size: cover;
    background-repeat: no-repeat;
}


基本上就是这样。

JsFiddle

希望对您有所帮助!