You can do this with flexbox quite easily. This is my transition, and then returning to the above solution for browsers that do not support flexbox. flexbox Support is huge these days, especially when IE 8 9 and 10 go away.
The trick is to use alignment-content: center to align the center of the icons in a circle and use the alignment elements: center to vertically align the icon in the circle.
Check out this great resource on flexbox . See here for an example pen http://codepen.io/celsowhite/pen/pgVegE .
HTML:
<ul class="social_links"> <li><a href="" target="_blank"> <i class="fa fa-envelope"></i> </a></li> <li><a href="" target="_blank"> <i class="fa fa-twitter"></i> </a></li> <li><a href="" target="_blank"> <i class="fa fa-facebook"></i> </a></li> </ul>
SCSS:
ul.social_links { display: block; padding: 20px 0px 0px; li { display: inline-block; font-size: 23px; padding: 0px 10px; } } ul.social_links i { background: black; border-radius: 50%; width: 50px; height: 50px; color: #fff; display: flex; flex-direction: row; justify-content: center; align-items: center; transition: all .5s ease-in-out; &:hover{ background: #555555; } }
source share