-1

I am seeing a strange issue where social footer icons are not centering? This is code I have inherited and just need someone else's pair of eyes to see if they know how to set the icons to be displayed in the center:

Code:

body { background-color: black }
<div class="socialfooter" style="padding-bottom: 15px; margin-bottom: 10px; text-align:center; margin-left:auto; margin-right:auto;">
  <p>
    <a style="float: left; margin-right: 12px;" href="https://www.instagram.com/balancecoffee" target="_blank" rel="noopener nofollow"><img loading="lazy" src="https://balancecoffee.co.uk/stage/wp-content/uploads/2020/07/Instagramwhite.svg" width="30px" height="30px"></a>
    <a style="float: left; margin-right: 12px;" href="https://www.facebook.com/balancecoffee20" target="_blank" rel="noopener nofollow"><img loading="lazy" src="https://balancecoffee.co.uk/stage/wp-content/uploads/2020/07/Facebookwhite.svg" width="29px" height="29px"></a>
  </p>
  <p>
    <a style="float: left; margin-right: 12px;" href="https://twitter.com/BalanceCoffeeUK" target="_blank" rel="noopener nofollow"><img loading="lazy" src="https://balancecoffee.co.uk/stage/wp-content/uploads/2020/07/Twitterwhite.svg" width="30px" height="30px"></a>
  </p>
  <p>
    <a style="float: left; margin-right: 12px;" href="https://www.pinterest.com/balancecoffee" target="_blank" rel="noopener nofollow"><img loading="lazy" src="https://balancecoffee.co.uk/stage/wp-content/uploads/2020/07/Pinterestwhite.svg" width="30px" height="30px"></a>
  </p>
</div>

How it looks at the moment:

enter image description here

mplungjan
  • 169,008
  • 28
  • 173
  • 236
BruceyBandit
  • 3,978
  • 19
  • 72
  • 144

2 Answers2

2

Just use

display: flex;
justify-content: center;

to the .socialfooter class

body {
  background: black;
}
.socialfooter {
    display: flex;
    justify-content: center;
  }
<div class="socialfooter" style="padding-bottom: 15px; margin-bottom: 10px; text-align:center; margin-left:auto; margin-right:auto;">
  <p>
    <a style="float: left; margin-right: 12px;" href="https://www.instagram.com/balancecoffee" target="_blank" rel="noopener nofollow"><img loading="lazy" src="https://balancecoffee.co.uk/stage/wp-content/uploads/2020/07/Instagramwhite.svg" width="30px" height="30px"></a>
    <a style="float: left; margin-right: 12px;" href="https://www.facebook.com/balancecoffee20" target="_blank" rel="noopener nofollow"><img loading="lazy" src="https://balancecoffee.co.uk/stage/wp-content/uploads/2020/07/Facebookwhite.svg" width="29px" height="29px"></a>
  </p>
  <p>
    <a style="float: left; margin-right: 12px;" href="https://twitter.com/BalanceCoffeeUK" target="_blank" rel="noopener nofollow"><img loading="lazy" src="https://balancecoffee.co.uk/stage/wp-content/uploads/2020/07/Twitterwhite.svg" width="30px" height="30px"></a>
  </p>
  <p>
    <a style="float: left; margin-right: 12px;" href="https://www.pinterest.com/balancecoffee" target="_blank" rel="noopener nofollow"><img loading="lazy" src="https://balancecoffee.co.uk/stage/wp-content/uploads/2020/07/Pinterestwhite.svg" width="30px" height="30px"></a>
  </p>
</div>
Imran
  • 440
  • 4
  • 15
1

Just remove the float: left on the links that is causing them to, well, actually float to the left, and change the paragraphs to display: inline-block;

body { background-color: black }

.socialfooter p {
  display: inline-block;
}
<div class="socialfooter" style="padding-bottom: 15px; margin-bottom: 10px; text-align:center; margin-left:auto; margin-right:auto;">
  <p>
    <a style="margin-right: 12px;" href="https://www.instagram.com/balancecoffee" target="_blank" rel="noopener nofollow"><img loading="lazy" src="https://balancecoffee.co.uk/stage/wp-content/uploads/2020/07/Instagramwhite.svg" width="30px" height="30px"></a>
    <a style="margin-right: 12px;" href="https://www.facebook.com/balancecoffee20" target="_blank" rel="noopener nofollow"><img loading="lazy" src="https://balancecoffee.co.uk/stage/wp-content/uploads/2020/07/Facebookwhite.svg" width="29px" height="29px"></a>
  </p>
  <p>
    <a style="margin-right: 12px;" href="https://twitter.com/BalanceCoffeeUK" target="_blank" rel="noopener nofollow"><img loading="lazy" src="https://balancecoffee.co.uk/stage/wp-content/uploads/2020/07/Twitterwhite.svg" width="30px" height="30px"></a>
  </p>
  <p>
    <a style="margin-right: 12px;" href="https://www.pinterest.com/balancecoffee" target="_blank" rel="noopener nofollow"><img loading="lazy" src="https://balancecoffee.co.uk/stage/wp-content/uploads/2020/07/Pinterestwhite.svg" width="30px" height="30px"></a>
  </p>
</div>
Constantin Groß
  • 10,719
  • 4
  • 24
  • 50