Images aren't full width


#1

I thought I was consistent in each of the sections. There are background images for
- Main
- Feature
- Footer

The Main image spans the entire preview screen but the Feature and Footer ones don't.

Here is my CSS code. If you can point out how I should better organize as well, I'd appreciate it. I still haven't wrapped my head about how to organize the CSS sections.

html, body {
  margin: 0;
}

h1, h2, a {
  font-family: 'Oswald', sans-serif;
}

p {
  font-family: Helvetica, Arial, sans-serif; 
}

.container {
  width: 940px;
  margin: 0 auto;
}

/* Main */
.main {
  height: 600px;
  text-align:center;
  background:url('https://s3.amazonaws.com/codecademy-content/projects/move/bg.jpg');
  background-size:cover;
}

.main h1 {
  font-size: 150px;
  color:white;
  text-transform:uppercase;
  margin:0;
}

.main p {
  font-size: 18px;
  color:white;
  margin:0 0 20px 0;
}

.main .btn {
  text-transform:uppercase;
  background:black;
  color:white;
  padding:10px 25px;
  text-decoration:none;
  margin:auto;
  transition:0.5s;
}

.main .btn:hover {
  background:#ffa800;
  color:#000;
  transition:0.5s;
}

/* Supporting */
.supporting {
  text-align: center;
  padding: 50px 0 80px;
  background:#1c1c1c;
}

.supporting .col {
  float: left;
  width: 28%;
  padding: 10px;
  position:inline;
}

.supporting h1,
.supporting h2 {
  color: #ffa800;
  font-size: 20px;
  margin-bottom: 10px;
  text-transform:uppercase;

}

.clearfix {
  clear: both;
}

.supporting p {
  color: #efefef;
  margin-bottom: 20px;
  line-height: 20px;
  font-size: 12px;
}

.supporting .btn {
  background-color: #eee;
  color: #1c1c1c;
  font-size: 18px;
  padding: 8px 30px;
  text-decoration: none;
  display: inline-block;
  text-transform:uppercase;
  transition:0.5s;
}

.supporting .btn:hover {
  background:#ffa800;
  color:#000;
  transition:0.5s;
}

/* Feature */
.feature .container{
  height: 600px;
  width:940px;
  martin:0 auto;
  background:url('https://s3.amazonaws.com/codecademy-content/projects/move/feature.jpg');
  background-size:cover;
}

.feature h1 {
  color: #fff;
  font-size: 40px;
  margin: 0;
  padding:50px 0 0;
  text-transform:uppercase;
  text-align:center;
  position:relative;
  top:280px;
}

.feature supporting h2 {
  color: #fff;
  font-size: 40px;
  margin: 0;
  padding:50px 0 0;
  text-transform:uppercase;
  text-align:center;
  position:relative;
}

/* Footer */
.footer .container {
  height: 600px;
  width:940px;
  background:url('https://s3.amazonaws.com/codecademy-content/projects/move/footer.jpg');
  background-size:cover;
  top:280px;
}

.footer .container .btn {
  background-color: #1c1c1c;
  color: #fff;
  font-size: 18px;
  padding: 8px 30px;
  text-decoration: none;
  text-align:center;
  display: inline-block;
}

.footer .container .btn:hover {
  background:#ffa800;
  color:#000;
}

.footer h1,
.footer h2 {
  color: #fff;
  font-size: 40px;
  margin: 0 0 20px 0;
  padding:50px 0 0;
  text-align:center;
}

.footer p {
  color: #fff;
  margin: 0 0 20px 0;
  font-size: 18px;
}


@media (min-width:600px) {
  .main h1 {
    font-size: 200px;
  }

  .supporting .col {
    width: 30%;
  }

  .supporting h2 {
    font-size: 40px;
  }

  .supporting p {
    font-size: 14px;
  }

  .feature h2 {
    font-size: 60px;
  }
}

#2

Hey Santiago,

You need to be setting the background image on the parent element, not the container :slight_smile: So, instead of this:

.feature .container {
  /* ... */
  background: url('https://s3.amazonaws.com/codecademy-content/projects/move/feature.jpg');
  background-size: cover;
}

...you'd do this:

     /* ↓ no `.container`! */
.feature {
  /* ... */
  background: url('https://s3.amazonaws.com/codecademy-content/projects/move/feature.jpg');
  background-size: cover;
}

Basically, the reason for this is that the way the Bootstrap grid works is, a container is a certain width, but not full width. So when you want something to be full width (like with this background), you have to use the parent element, and for stuff using a grid, you put that inside the container :slight_smile:


#3

Thank you, I think I put the image into the container because in the middle Feature section there is a section that does not have the image background. I'll rebuild the CSS and try to see how I managed to organize the Main section as that one also has the same type of layout (Image then black band with text.

BTW, I did not use Bootstrap in this case. This exercise required me to use standard CSS.

Thanks again. I'll go fix this now and post back if I run into problems.


#4

All better now. Here is what it looks like:

https://output.jsbin.com/waqisudobo