Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Four Column Layout Not Resizing to Screen Size

I’m trying to add a footer to my website. I used W3schools four-column layout: linked here. When I tried to add the resizing it was not working. I tried to change it from affecting width to color, and that worked, so I know it’s not a problem with recognizing screen size or anything with an incorrect class/id name.

.footer {
  padding-top: 10px;
  padding-bottom: 10px;
  width: 100%;
  background-color: #1F363D;
  text-align: center;
  color: white;
}

.footer-column {
  float: left;
  width: 20%;
  height: 100%;
}

@media screen and (max-width: 600px) {
  .footer-column {
    width: 100%;
  }
}

.footer a:link {
  color: white;
  font-size: 12px;
}

.footer a:visited {
  color: white;
}

.footer a:hover {
  color: white;
}

.footer a:active {
  color: white;
}
<div class="footer">
  <div style="width:100%; display: flex; justify-content: space-evenly; align-text: center; font-size: 13px;">
    <div class="footer-column">
      <p style="font-size: 15px;">Pages</p>
      <a href="/index.html">Home</a><br>
      <a href="/projects.html">Projects</a><br>
      <a href="/contact.html">Contact</a><br>
      <a href="/about.html">About</a>
    </div>
    <div class="footer-column">
      <p>Projects</p>
      <a href="/projects/mastermind.html">Mastermind</a><br>
      <a href="/projects/simon.html">Simon</a><br>
      <a href="/projects/trivia.html">Trivia</a><br>
    </div>
    <div class="footer-column">
      <p>Column 3</p>
    </div>
    <div class="footer-column">
      <p>Column 4</p>
    </div>
  </div>
  <p style="color: white; text-align: center; font-family: monospace;">© 2022 Jake Poyer</p>
</div>

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Remove the second parent with the inline styles and set flex onto the main parent .footer. Then set your .footer-column width to 100% with a media query and you can also instruct the browser to change from the default flex-row to flex-direction: column; at the same breaking point so it uses all available space.

.footer {
  padding-top: 10px;
  padding-bottom: 10px;
  width: 100%;
  background-color: #1F363D;
  text-align: center;
  color: white;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
}

.footer-column {
  width: calc(100%/4);
  height: 100%;
}

@media screen and (max-width: 600px) {
  .footer-column {
    width: 100%;
  }
  .footer {
    flex-direction: column;
  }
}

.footer a:link {
  color: white;
  font-size: 12px;
}

.footer a:visited {
  color: white;
}

.footer a:hover {
  color: white;
}

.footer a:active {
  color: white;
}
<div class="footer">
  <div class="footer-column">
    <p style="font-size: 15px;">Pages</p>
    <a href="/index.html">Home</a><br>
    <a href="/projects.html">Projects</a><br>
    <a href="/contact.html">Contact</a><br>
    <a href="/about.html">About</a>
  </div>
  <div class="footer-column">
    <p>Projects</p>
    <a href="/projects/mastermind.html">Mastermind</a><br>
    <a href="/projects/simon.html">Simon</a><br>
    <a href="/projects/trivia.html">Trivia</a><br>
  </div>
  <div class="footer-column">
    <p>Column 3</p>
  </div>
  <div class="footer-column">
    <p>Column 4</p>
  </div>
  <p style="color: white; text-align: center; font-family: monospace; width: 100%;">© 2022 Jake Poyer</p>
</div>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading