-1

Top and Bottom Padding on a div is not being applied equally. However, when you change the size of the browser window the padding is applied equally.

I've added padding: 50px 0px; on a div but it is not being applied equally.

div.banners {
  padding: 50px 0px;
  margin: 0px 0px;
  background-color: #f60;
}

div.banners-third {
  width: 30%;
  margin-right: 5%;
  float: left;
  text-align: center;
}

div.banners-third-last {
  margin: 0px;
}

@media screen and (max-width: 820px) {
  div.banners-third {
    width: 47.5%;
  }
  div.banners-third-second {
    margin: 0px;
  }
  div.banners-third-last {
    padding: 20px 0px 0px;
    width: auto;
    clear: both;
    float: none;
  }
}

@media screen and (max-width:720px) {
  div.banners-third {
    width: 33%;
    margin-top: 25px;
  }
  div.banners-third-last {
    padding: 0px 0px 0px;
    width: auto;
    clear: both;
    float: none;
  }
  div.banners-mobile-collapse {
    width: auto;
    margin-right: 0px;
    float: none;
  }
}
<DIV class="banners">

  <DIV class="banners-third banners-mobile-collapse">
    <h2>Banner 1</h2>
  </DIV>

  <DIV class="banners-third banners-third-second banners-mobile-collapse">
    <h2>Banner 2</h2>
  </DIV>

  <DIV class="banners-third banners-third-last">
    <h2>Banner 3</h2>
  </DIV>
</DIV>

I expected the 50px to be applied to the bottom of the div.

BugsArePeopleToo
  • 2,976
  • 1
  • 15
  • 16
Ike Evens
  • 13
  • 5

2 Answers2

-1

My dear, if I understand your doubt, do you want to pad down? If so try to use too;

div.banners {
  padding: 50px 0px;
  margin: 0px 0px;
  background-color: #f60;
  padding-bottom: 50px !important;
}

From what I saw is supposed to be working; See if there is no other class disrupting the browser.

-1

Just use display:flex in div.banners

div.banners {
  display:flex;
  padding: 50px 0px;
  margin: 0px 0px;
  background-color: #f60;
}

div.banners-third {
  width: 30%;
  margin-right: 5%;
  float: left;
  text-align: center;
}

div.banners-third-last {
  margin: 0px;
}

@media screen and (max-width: 820px) {
  div.banners-third {
    width: 47.5%;
  }
  div.banners-third-second {
    margin: 0px;
  }
  div.banners-third-last {
    padding: 20px 0px 0px;
    width: auto;
    clear: both;
    float: none;
  }
}

@media screen and (max-width:720px) {
  div.banners-third {
    width: 33%;
    margin-top: 25px;
  }
  div.banners-third-last {
    padding: 0px 0px 0px;
    width: auto;
    clear: both;
    float: none;
  }
  div.banners-mobile-collapse {
    width: auto;
    margin-right: 0px;
    float: none;
  }
}
<DIV class="banners">

  <DIV class="banners-third banners-mobile-collapse">
    <h2>Banner 1</h2>
  </DIV>

  <DIV class="banners-third banners-third-second banners-mobile-collapse">
    <h2>Banner 2</h2>
  </DIV>

  <DIV class="banners-third banners-third-last">
    <h2>Banner 3</h2>
  </DIV>
</DIV>
novruzrhmv
  • 639
  • 5
  • 13