2

I am currently making my first ever website as a school project and it is absolutely forbidden to use floats for my layout. So I have the following footer:

.footer {
    width: 100%;
    position: relative;
    height: auto;
    background-color: #070617;
    margin-top: 5px;
  }
  .footer .col {
    width: 190px;
    height: auto;
    float:left;
    box-sizing: border-box;
    -webkit-box-sizing: border-box;
    -moz-box-sizing: border-box;
    padding: 0px 20px 20px 20px;
  }
  .footer .col h1 {
    margin: 0;
    padding: 0;
    font-family: inherit;
    font-size: 12px;
    line-height: 17px;
    padding: 20px 0px 5px 0px;
    color: rgba(255,255,255,0.2);
    font-weight: normal;
    text-transform: uppercase;
    letter-spacing: 0.250em;
  }
  .footer .col ul {
    list-style-type: none;
    margin: 0;
    padding: 0;
  }
  .footer .col ul li {
    color: #999999;
    font-size: 14px;
    font-family: inherit;
    font-weight: bold;
    padding: 5px 0px 5px 0px;
    cursor: pointer;
    transition: .2s;
    -webkit-transition: .2s;
    -moz-transition: .2s;
  }
  .social ul li {
    display: inline-block;
    padding-right: 5px !important;
  }
  
  .social a {
      text-decoration: none;
      color:#999999;
  }

  .social a:hover {
    color: #ffffff;
    transition: .1s;
    -webkit-transition: .1s;
    -moz-transition: .1s;
    
}
  .footer .col ul li:hover {
    color: #ffffff;
    transition: .1s;
    -webkit-transition: .1s;
    -moz-transition: .1s;
  }
  .clearfix {
    clear: both;
  }
     <div class="footer">
        <div class="contain">
        <div class="col">
          <h1>Company</h1>
          <ul>
            <li>About</li>
            <li>Social</li>
            <li>Get in touch</li>
          </ul>
        </div>
        
        
        <div class="col">
          <h1>Support</h1>
          <ul>
            <li>Contact us</li>
          </ul>
        </div>
        <div class="col social">
          <h1>Social</h1>
          <ul>
           <li> <a href="#">Facebook</a></li>
           <li> <a href="#">Twitter</a></li>
           <li> <a href="#">Instagram</a></li>
           <li> <a href="#">Education</a></li>
          </ul>
        </div>
      <div class="clearfix"></div>
      </div>
      </div>

But in my CSS .footer .col I am using a float. How can I achieve the same result of the float with something else like flexbox? I already tried things like justify content but I couldn't get the same result.

Michal J Figurski
  • 1,262
  • 1
  • 11
  • 18

2 Answers2

1

You can try using, and reading the Bootstrap documentation to achieve the same results without using a lot of css and do not use the float. Here You can fin the text alignment and this can be useful to you.

Check out the "text-right", "text-left", "text-center" tags, try all these classes that bootstrap provides, and you will not be in need to create clases :)

By the way if you're using bootstrap you have to use correctly the container as shown here, correct the mispelled word container :)

<div class="footer">
        <div class="container">
        <div class="col">
          <h1>Company</h1>
          <ul>
            <li>About</li>
            <li>Social</li>
            <li>Get in touch</li>
          </ul>
        </div>
        
        
        <div class="col">
          <h1>Support</h1>
          <ul>
            <li>Contact us</li>
          </ul>
        </div>
        <div class="col social">
          <h1>Social</h1>
          <ul>
           <li> <a href="#">Facebook</a></li>
           <li> <a href="#">Twitter</a></li>
           <li> <a href="#">Instagram</a></li>
           <li> <a href="#">Education</a></li>
          </ul>
        </div>
      <div class="clearfix"></div>
   </div>
 </div>
0

Hi broder great work to achive your goal with flex box easy to do : juste add this lines in your css and remove float form your footer & play around with other value in the comment ("_") Have Fun good Luck:

.contain {
    display: flex;
    justify-content: center; /* flex-start(by default )/ flex-end/ center */
}
Mahdi-Soultana
  • 144
  • 1
  • 9