PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Friday, November 18, 2022

[FIXED] How do I align these pictures vertically?

 November 18, 2022     alignment, css, html, vertical-alignment     No comments   

Issue

I'm creating a footer, and I would like to align the images of social networks vertically and automatically. As it has an increase in the size of the source of the contacts, the images are up. And I do not know how to proceed.

My code on jsfiddle: Demo Code

HTML

<!DOCTYPE html>
<title>Teste</title>

<body>
  <footer class="footer">
    <div class="content">
      <div class="footer-right">
        <p><b>(43)3333-3333</b></p>
        <p>contact@contact.com</p>
      </div>
      <div class="footer-left">
        <ul>
          <li>
            <a href="#"><img src="http://imgur.com/RVvPQt9.png" alt="Twitter"></a>
          </li>
          <li>
            <a href="#"><img src="http://imgur.com/LsqUBIh.png" alt="Facebook"></a>
          </li>
          <li>
            <a href="#"><img src="http://imgur.com/8PhKmDe.png" alt="Instagram"></a>
          </li>
          <li>
            <a href="#"><img src="http://imgur.com/hDSPEMm.png" alt="Linkedin"></a>
          </li>
        </ul>
      </div>
    </div>
  </footer>
</body>

CSS

* {
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Source Sans Pro', sans-serif;
}

.content {
  margin: 0 auto;
  max-width: 1100px;
  padding: 0 4% 0 4%;
}

li {
  list-style: none;
}

.footer {
  background-color: rgba(158, 158, 158, 0.42);
  box-shadow: 0 1px 1px 0 rgba(0, 0, 0, 0.12);
  box-sizing: border-box;
  width: 100%;
  text-align: left;
  padding: 15px 0;
  overflow: hidden;
}

.footer .footer-right {
  float: right;
}

.footer .footer-right {
  font-size: 18px;
  text-align: right;
}

.footer .content .footer-left {
  float: left;
}

.footer .content .footer-left > ul > li {
  display: inline-block;
}

.footer > .content > .footer-left > ul > li > a {
  display: block;
}

.footer > .content > .footer-left > ul > li > a > img {
  height: 30px;
  width: 30px;
}


/*MEDIA QUERIES*/

@media screen and (max-width: 400px) {
  .footer > .content > .footer-right,
  .footer-left {
    float: none !important;
    text-align: center;
  }
  .footer > .content > .footer-right {
    margin-bottom: 10px;
  }
}

Solution

Use table display css - the table-cell causes the floating to work and the table-header-group and table-footer-group cause the reordering.

* {
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Source Sans Pro', sans-serif;
}

.content {
    margin: 0 auto;
    max-width: 1100px;
    padding: 0 4% 0 4%;
    min-width:92%;
    display:table;
}

li {
    list-style: none;
}

.footer {
    background-color: rgba(158, 158, 158, 0.42);
    box-shadow: 0 1px 1px 0 rgba(0, 0, 0, 0.12);
    box-sizing: border-box;
    width: 100%;
    text-align: left;
    padding: 15px 0;
    overflow: hidden;
}

.footer .footer-right {
    display:table-cell;
    width:50%;
}

.footer .footer-right {
    font-size: 18px;
    text-align: right;
    width:50%;
}

.footer .content .footer-left {
    display:table-cell;
    vertical-align:middle;
}

.footer .content .footer-left > ul > li {
    display: inline-block;
}

.footer > .content > .footer-left > ul > li > a {
    display: block;
}

.footer > .content > .footer-left > ul > li > a > img {
    height: 30px;
    width: 30px;
}


/*MEDIA QUERIES*/

@media screen and (max-width: 400px) {
    .footer > .content > .footer-left {
        display:table-footer-group;
        width:100%;
        float:none;
        text-align: center;
    }
    .footer > .content > .footer-right {
        display:table-header-group;
        margin-bottom: 10px;
        float:none;
        width:100%;
    }
    .footer > .content > .footer-right p {
        width:100%;
        display:block;
        text-align: center;
    }
}
<!DOCTYPE html>
    <title>Teste</title>
<body>
    <footer class="footer">
        <div class="content">
            <div class="footer-left">
                <ul>
                    <li>
                        <a href="#"><img src="http://imgur.com/RVvPQt9.png"
                                alt="Twitter"></a>
                    </li>
                    <li>
                        <a href="#"><img src="http://imgur.com/LsqUBIh.png"
                                alt="Facebook"></a>
                    </li>
                    <li>
                        <a href="#"><img src="http://imgur.com/8PhKmDe.png"
                                alt="Instagram"></a>
                    </li>
                    <li>
                        <a href="#"><img src="http://imgur.com/hDSPEMm.png"
                                alt="Linkedin"></a>
                    </li>
                </ul>
            </div>
            <div class="footer-right">
                <p><b>(43)3333-3333</b></p>
                <p>contact@contact.coma</p>
                <p><b>(43)3333-3333</b></p>
                <p>contact@contact.coma</p>
            </div>
        </div>
    </footer>
</body>



Answered By - WEBjuju
Answer Checked By - Robin (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing