0

I have 3 columns in my footer (f-box). I want them to have equal height. I don't want to use flexbox for this one. I am trying to achieve the result using - display:table on my container of the boxes and make display:table-cell for every box. But it doesn't work. Why? How to do it with this display: table method

@import url("https://fonts.googleapis.com/css2?family=Open+Sans:wght@300;400;600;700;800&family=Quantico:wght@400;700&display=swap");

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: "Open Sans", sans-serif;
  line-height: 1.5;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  font-family: "Quantico", sans-serif;
  margin-bottom: 20px;
}

p {
  font-size: 15px;
  color: #666;
  line-height: 26px;
  margin-bottom: 15px;
}

a {
  font-family: "Quantico", sans-serif;
  text-decoration: none;
  color: #111;
}

ul {
  list-style: none;
}

img {
  width: 100%;
  display: block;
}

/* Theme */
.container {
  margin: auto;
  max-width: 1500px;
  padding: 0 15px;
}

.logo {
  font-size: 30px;
  padding: 20px 0;
  float: left;
  margin: 0;
}

.main-color {
  color: #009603;
}

.btn {
  display: inline-block;
  text-transform: uppercase;
  background: #009603;
  color: #fff;
  padding: 14px 30px;
  font-weight: 700;
}

/* Nav */

nav {
  overflow: hidden;
  text-transform: uppercase;
}

nav ul {
  float: right;
}

nav ul li {
  float: left;
  margin-right: 32px;
  position: relative;
}

nav ul li a {
  display: block;
  padding: 31px 8px;
  font-weight: 700;
}

nav ul li a:after {
  position: absolute;
  left: 0;
  bottom: 0;
  height: 3px;
  width: 100%;
  background: #009603;
  content: "";
  opacity: 0;
  transition: all 0.3s;
}

nav ul li.active a:after {
  opacity: 1;
}

nav ul li:hover > a:after {
  opacity: 1;
}

/* Showcase */
#showcase {
  background: url("../img/bg.jpg") no-repeat center center/cover;
  height: 900px;
}

#showcase .showcase-content {
  color: #fff;
  text-align: center;
  padding-top: 300px;
}

#showcase .showcase-content h2 {
  font-size: 60px;
  font-weight: 700;
  text-transform: uppercase;
}

#showcase .showcase-content p {
  margin-bottom: 30px;
  line-height: 30px;
  color: #fff;
}

/* Features */
#features {
  padding-bottom: 60px;
}

#features .container {
  margin-top: -70px;
  max-width: 1400px;
  overflow: hidden;
}

#features .box {
  background: #fff;
  float: left;
  max-width: 30%;
  margin: 0 15px 30px 15px;
  padding: 10px 10px 18px 10px;
  box-shadow: 0px 10px 25px rgba(206, 206, 206, 0.5);
  text-align: center;
}

#features .box img {
  margin-bottom: 28px;
}

#features .box h3 {
  color: #191039;
  font-weight: 700;
  text-transform: uppercase;
  margin-bottom: 10px;
  font-size: 30px;
}

/* Footer */
footer {
  padding-top: 70px;
  overflow: hidden;
  background-color: #000;
}

footer .container {
  max-width: 1400px;
  display: table;
}

footer .f-box {
  display: table-cell;
  float: left;
  max-width: 33.3%;
  margin-bottom: 30px;
  padding: 0 15px;
}

footer .logo {
  padding-top: 0;
  color: #fff;
  text-transform: uppercase;
  float: none;
}

footer p {
  color: #c4c4c4;
  margin-bottom: 20px;
}

footer .social i {
  color: #fff;
  margin-right: 20px;
}

footer h5 {
  color: #fff;
  text-transform: uppercase;
  font-size: 20px;
  font-weight: 700px;
  margin-bottom: 35px;
  padding-top: 5px;
}

footer img {
  float: left;
  width: calc(33.33% - 5px);
  margin-right: 5px;
}

footer form {
  position: relative;
}

footer input {
  width: 100%;
  height: 50px;
  font-size: 15px;
  color: #c4c4c4;
  padding-left: 20px;
  border: 1px solid #009603;
  background: transparent;
}

footer form button {
  font-size: 18px;
  color: #fff;
  background: #009603;
  height: 50px;
  width: 50px;
  border: none;
  position: absolute;
  right: 0;
  top: 0;
}
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Pacocha | Garden Projects</title>
    <link rel="stylesheet" href="css/style.css" />
    <script
      src="https://kit.fontawesome.com/1685e275a4.js"
      crossorigin="anonymous"
    ></script>
  </head>
  <body>
    <header>
      <nav>
        <div class="container">
          <a href="index.html">
            <h1 class="logo"><i class="fas fa-leaf main-color"></i> Pacocha</h1>
          </a>
          <ul>
            <li class="active"><a href="index.html">Home</a></li>
            <li><a href="about.html">About</a></li>
            <li><a href="services.html">Services</a></li>
          </ul>
        </div>
      </nav>

      <div id="showcase">
        <div class="container">
          <div class="showcase-content">
            <h2>Garden Projects</h2>
            <p>
              We have the best home improvement projects, expert advice, and DIY
              home improvement ideas for your home. <br />
              You can create your dream home with smart planning and the right
              home improvement contractors.
            </p>
            <a href="about.html" class="btn">About Us</a>
          </div>
        </div>
      </div>
    </header>

    <!-- Features -->
    <section id="features">
      <div class="container">
        <div class="box">
          <img src="img/feat1.jpeg" alt="" />
          <h3>Gardening</h3>
          <p>
            Lorem ipsum, dolor sit amet consectetur adipisicing elit. Maiores
            magnam reprehenderit aspernatur neque nam ipsum enim, vitae minus
            totam voluptates.
          </p>
        </div>
        <div class="box">
          <img src="img/feat2.jpg" alt="" />
          <h3>Decorating</h3>
          <p>
            Lorem ipsum, dolor sit amet consectetur adipisicing elit. Maiores
            magnam reprehenderit aspernatur neque nam ipsum enim, vitae minus
            totam voluptates.
          </p>
        </div>
        <div class="box">
          <img src="img/feat3.jpg" alt="" />
          <h3>Ideas</h3>
          <p>
            Lorem ipsum, dolor sit amet consectetur adipisicing elit. Maiores
            magnam reprehenderit aspernatur neque nam ipsum enim, vitae minus
            totam voluptates.
          </p>
        </div>
      </div>
    </section>

    <footer>
      <div class="container">
        <div class="f-box">
          <h1 class="logo"><i class="fas fa-leaf main-color"></i> Pacocha</h1>
          <p>
            Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ratione
            corporis nostrum ex perferendis! Adipisci, molestias.
          </p>
          <div class="social">
            <a href="index.html"><i class="fab fa-facebook-f"></i></a>
            <a href="index.html"><i class="fab fa-twitter"></i></a>
            <a href="index.html"><i class="fab fa-youtube"></i></a>
            <a href="index.html"><i class="fab fa-instagram"></i></a>
          </div>
        </div>
        <div class="f-box">
          <h5>Instagram</h5>
          <img src="img/insta1.jpg" alt="" />
          <img src="img/insta2.jpg" alt="" />
          <img src="img/insta3.jpg" alt="" />
        </div>
        <div class="f-box">
          <h5>Subscribe</h5>
          <p>
            Lorem ipsum, dolor sit amet consectetur adipisicing elit.
            Necessitatibus, vel?
          </p>
          <form action="">
            <input type="email" placeholder="Email" />
            <button type="submit"><i class="fa fa-send"></i></button>
          </form>
        </div>
      </div>
    </footer>
  </body>
</html>
WebByDima
  • 43
  • 8

1 Answers1

1

you just need this css

footer {
    padding: 70px 0;
}

footer .f-box {
    display: table-cell;
    float: none;
    width: 33.3%;
    margin-bottom: 30px; /*the margin property is not applicable to display:table-cell elements.*/
    padding: 0 15px;
}

and it will behave like this - equal column height

enter image description here

Rahul
  • 4,294
  • 1
  • 10
  • 12
  • It worked, but my margin-bottom vanished. Why? – WebByDima Apr 19 '20 at 07:31
  • 2
    its because the margin property is not applicable to display:table-cell elements. – Rahul Apr 19 '20 at 07:35
  • Oh, I see. While we are here, do you maybe know a way to align content vertically to center without using flexbox? I am trying to do things with floats only method and I wonder can I somehow do a align-items: center to a "float item" without using flexbox? – WebByDima Apr 19 '20 at 07:37
  • is it related to footer or something else ? if you want you can create another question as well over there I or someone could give you better answer and you could describe your question in a better way too – Rahul Apr 19 '20 at 07:41