Junction CSS background image


#1

I am having trouble getting the background image to fill up the entire body in my browser window when it is a small size. I have not encountered this problem with other exercises in HTML/CSS and am wondering if there something linked to bootstrap that is preventing the background image from covering the entire body. Reading some forum questions, I saw that .jumbotron was a default background color of white. I set .jumbotron background to 'none.' Is there something else that I missing about background images in this exercise?

<!doctype html>
<html>
  <head>
    <link rel="stylesheet" href="https://s3.amazonaws.com/codecademy-content/projects/bootstrap.min.css">
    <link href='https://fonts.googleapis.com/css?family=Merriweather' rel='stylesheet' type='text/css'>
    <link rel="stylesheet" href="style.css">
  </head>
  <body>
    <div class="header">
      <div class="container">
       
      </div>
    </div>


    <div class="jumbotron">
      <div class="container">
        
      </div>
    </div>

    <div class="supporting">
      <div class="container">
        
      </div>
    </div>
  </body>
</html>

html, body {
  margin: 0;
  padding: 0;
  font-family: 'Merriweather', serif;
}

body {
  background-image: url("https://s3.amazonaws.com/codecademy-content/projects/junction/bg.jpg");
  background-repeat: no-repeat;
  background-size: cover;
  
}

.container {
  max-width:940px;
}

/* Header */
.header {
  padding: 10px 0;
}

/* Jumbotron */
.jumbotron {
  position: relative;
  top: 50px;
  text-shadow: 0 2px 3px rgba(0,0,0,.4);
  background: none;
}

/* Supporting */
.supporting {
  margin-top: 40px;
  text-shadow: 0 2px 3px rgba(0,0,0,.4);
  background: none;
}

#2

body {
  background-image: url("https://s3.amazonaws.com/codecademy-content/projects/junction/bg.jpg");
  background-repeat: no-repeat;
  background-size: cover;  
}

Try setting other properties, like this:

background-attachment: fixed;
background-position: center center;



#3

I added background: center, but it still wasn't covering the whole body. Once I started adding more content to other sections of the body, the background began displaying correctly. Thanks for the reply and the tip!


#4

My pleasure. Glad you made it work :slight_smile:


#5

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.