Search code examples
csslayoutmarginfooterjustify

css justify content issue in footer


I have a footer and want that my list items are left justified with my h3. Is there a way to do it?

Now company and social and other are a bit more left than the rest. I already put justify-content: center but it seems like the headers have a different center than my list items. Hope somebody can help me.

enter image description here

footer {
  width: 100%;
  /*breite: 100%*/
  padding: 0;
  margin: 0;
  background-color: #5490dd;
  /*Hintergrundfarbe*/
}

.footer-items {
  width: 80%;
  margin: auto;
  display: flex;
  /*bringt alle Teile in eine Linie*/
}

.footer-column {
  z-index: 2;
  width: 33.33%;
  /*drittelt den Platz im footer*/
  text-align: center;
}

.footer-column ul {
  list-style: none;
  /*entfernt Anstriche*/
}

.footer-column ul li {
  margin: 0;
  padding-top: 5px;
}

.footer-column ul li a {
  text-decoration: none;
  /*entfernt das die Links unterstrichen sind*/
  color: rgb(230, 230, 230);
  list-style: none;
}
<footer>

  <div class="footer-items">

    <div class="footer-column">
      <h3 class="company">Company</h3>
      <ul>
        <li><a href="kontakt.html">Kontakt</a></li>
        <li><a href="about.html">Über Uns</a></li>
        <li><a href="impressum.html">Impressum</a></li>
      </ul>
    </div>

    <div class="footer-column">
      <h3 class="social">Social</h3>
      <ul>
        <li><a>Twitter</a></li>
        <li><a>Instagram</a></li>
        <li><a>Reddit</a></li>
      </ul>
    </div>

    <div class="footer-column">
      <h3 class="other">other</h3>
      <ul>
        <li><a>other1</a></li>
        <li><a>other2</a></li>
      </ul>
    </div>

  </div>


Solution

  • Why do you need ul li without their styles? Aslo ul has its defaults, which maybe you don't want to use. Use div.

    Look into the snippet.

    I added padding-bottom to .footer-column and changed ul li to div in html and css

    If you want left alignment - remove text-align: center;

    footer {
      width: 100%;
      /*breite: 100%*/
      padding: 0;
      margin: 0;
      background-color: #5490dd;
      /*Hintergrundfarbe*/
    }
    
    .footer-items {
      width: 80%;
      margin: auto;
      display: flex;
      /*bringt alle Teile in eine Linie*/
    }
    
    .footer-column {
      z-index: 2;
      width: 33.33%;
      /*drittelt den Platz im footer*/
      /*text-align: center;*/
      padding-bottom: 16px;
    }
    
    .footer-column div {
      margin: 0;
      padding-top: 5px;
    }
    
    .footer-column div a {
      text-decoration: none;
      /*entfernt das die Links unterstrichen sind*/
      color: rgb(230, 230, 230);
      list-style: none;
    }
    <footer>
    
      <div class="footer-items">
    
        <div class="footer-column">
          <h3 class="company">Company</h3>
          <div><a href="kontakt.html">Kontakt</a></div>
          <div><a href="about.html">Über Uns</a></div>
          <div><a href="impressum.html">Impressum</a></div>
    
        </div>
    
        <div class="footer-column">
          <h3 class="social">Social</h3>
    
          <div><a>Twitter</a></div>
          <div><a>Instagram</a></div>
          <div><a>Reddit</a></div>
    
        </div>
    
        <div class="footer-column">
          <h3 class="other">other</h3>
    
          <div><a>other1</a></div>
          <div><a>other2</a></div>
    
        </div>
    
      </div>