Section with display block does not work correctly

1

I have the following problem: I opened a topic yesterday regarding some positions that were getting wrong, and that I was able to solve. However, another problem has appeared that consists of the following: In this image is the effect that I look for:

Andhere'stheeffectIgotfrommycode:

Sofarsogood,however,lookwhathappenswhenIresizethewebsite:

Noticethatonthescreenofthissiteyour<section>areonebelowtheother,withathinborderseparatingthetwo,andonthesideedgesdoesnothave,beingexactlyzeroed.

Nowthisismyresizedcanvas:

Realizethatmy<section>whocomesafter<header>alreadytakesadistancethatcouldnot,besidespresentingaborderontheleftsideandbeinghalfcrooked.Well,followmycodeforbetterunderstanding:

#sessao-1 {
  margin-top: 210px;
}
#img-info {
  margin: 0;
  padding: 0;
}
#img-info li {
  width: 33.333%;
  display: inline-block;
  float: left;
}
.img-1 {
  background-image: url(http://www.kkuodesign.com/wordpress/wp-content/uploads/2009/11/assassins-creed-game-widescreen-wallpaper.png);
  background-size: cover;
  background-repeat: no-repeat;
  padding-top: 59.42%;
  border-right: 7px solid #000;
}
.img-2 {
  background-image: url(http://www.1stwallpaper.com/wp-content/uploads/2015/05/the_last_of_us_video_games_hd_wallpapers-500x300.jpg);
  background-size: cover;
  background-repeat: no-repeat;
  padding-top: 59.42%;
}
.img-3 {
  background-image: url(http://www.1stwallpaper.com/wp-content/uploads/2015/06/Images-bakground-gaming-wallpaper-mortal-kombat-high-quality-hd-wallpapers-500x300.jpg);
  background-size: cover;
  background-repeat: no-repeat;
  padding-top: 59.42%;
  border-left: 7px solid #000;
}
.text {
  background-color: #fff;
  width: 100%;
  height: 300px;
}
.text h1 {
  font-family: 'Trade Winds', cursive;
  font-size: 2em;
  text-align: center;
  padding: 15px;
}
.text p {
  width: 350px;
  max-width: 95%;
  padding: 15px 40px;
  font-family: 'Roboto', sans-serif;
  font-size: .9em;
  font-style: italic;
  line-height: 20px;
}
@media(max-width: 800px) {
  #img-info li {
    display: block;
    float: none;
    width: 100%;
    border: none;
  }
  .text p {
    text-align: center;
    margin: 0 auto;
  }
}
<section id="sessao-1">
  <ul id="img-info">
    <li>
      <div class="img-1">
        <div class="text">
          <h1>Lorem Ipsum Dolor</h1>
          <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute
            irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.</p>
        </div>
      </div>
    </li>

    <li>
      <div class="img-2">
        <div class="text">
          <h1>Lorem Ipsum Dolor</h1>
          <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute
            irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.</p>
        </div>
      </div>
    </li>

    <li>
      <div class="img-3">
        <div class="text">
          <h1>Lorem Ipsum Dolor</h1>
          <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute
            irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.</p>
        </div>
      </div>
    </li>
  </ul>
</section>

Note: as I decrease the screen my letters begin to be superimposed by my background-color. I'm pretty sure the way I did my section is wrong.

    
asked by anonymous 31.07.2015 / 13:22

1 answer

0

Below is your modified and working code. I just made some modifications, I'll list them below and explain:

  • Instead of using border I used margin and left background of the parent black.
  • When adding the margins I used the #img-info li + li selector that selects the next sibling of li , causing the first one to run out of bounds.
  • The% of% of width has been reduced according to the margin value applied.
  • I put li on display:table .

* {
  margin: 0;
  padding: 0;
}
#sessao-1 {
  margin-top: 210px;
}
#img-info {
  margin: 0;
  padding: 0;
  background: #000;
  width: 100%;
  display: table;
}
#img-info li {
  width: 32.666666666666666666666666666667%;
  display: inline-block;
  float: left;
  overflow: hidden;
}
#img-info li + li {
  margin-left: 1%;
}
.img-1 {
  background-image: url(http://www.kkuodesign.com/wordpress/wp-content/uploads/2009/11/assassins-creed-game-widescreen-wallpaper.png);
  background-size: cover;
  background-repeat: no-repeat;
  padding-top: 59.42%;
}
.img-2 {
  background-image: url(http://www.1stwallpaper.com/wp-content/uploads/2015/05/the_last_of_us_video_games_hd_wallpapers-500x300.jpg);
  background-size: cover;
  background-repeat: no-repeat;
  padding-top: 59.42%;
}
.img-3 {
  background-image: url(http://www.1stwallpaper.com/wp-content/uploads/2015/06/Images-bakground-gaming-wallpaper-mortal-kombat-high-quality-hd-wallpapers-500x300.jpg);
  background-size: cover;
  background-repeat: no-repeat;
  padding-top: 59.42%;
}
.text {
  background-color: #fff;
  width: 100%;
  height: 300px;
}
.text h1 {
  font-family: 'Trade Winds', cursive;
  font-size: 2em;
  text-align: center;
  padding: 15px;
}
.text p {
  width: 350px;
  max-width: 95%;
  padding: 15px 40px;
  font-family: 'Roboto', sans-serif;
  font-size: .9em;
  font-style: italic;
  line-height: 20px;
}
@media(max-width: 800px) {
  #img-info li {
    display: block;
    float: none;
    width: 100%;
    border: none;
  }
  #img-info li + li {
    margin-top: 5px;
    margin-left: 0;
  }
  .text p {
    text-align: center;
    margin: 0 auto;
  }
}
<section id="sessao-1">
  <ul id="img-info">
    <li>
      <div class="img-1">
        <div class="text">
          <h1>Lorem Ipsum Dolor</h1>
          <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute
            irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.</p>
        </div>
      </div>
    </li>

    <li>
      <div class="img-2">
        <div class="text">
          <h1>Lorem Ipsum Dolor</h1>
          <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute
            irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.</p>
        </div>
      </div>
    </li>

    <li>
      <div class="img-3">
        <div class="text">
          <h1>Lorem Ipsum Dolor</h1>
          <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute
            irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.</p>
        </div>
      </div>
    </li>
  </ul>
</section>
    
02.09.2015 / 19:51