I am trying to create a pure html and css facebook icon for a my website. I think I have most of it done reasonably well. However, when I added a link to the HTML, the text "f" in the HTML was no longer centered horizontally within the div.
HTML
<div class="facebook" alt="facebook"><a href="#">f</a></div>
CSS
.facebook {
font-family:"Lucida Grande", "Lucida Sans Unicode", "Lucida Sans", Geneva, Verdana, sans-serif;
height: 40px;
width: 40px;
border-radius: 50%;
background: #1f3060;
background-position: center;
font-size:22px;
text-shadow: 1px 1px #000000;
transition-duration: 0.2s;
-moz-transition-duration: 0.2s;
-webkit-transition-duration: 0.2s;
-o-transition-duration: 0.2s;
transition-timing-function: ease-in;
-moz-transition-timing-function: ease-in;
-webkit-transition-timing-function: ease-in;
-o-transition-timing-function: ease-in;
-webkit-transform:rotate(-360deg);
-moz-transform:rotate(-360deg);
-o-transform:rotate(-360deg);
transform:rotate(-360deg);
}
.facebook a {
color: white;
vertical-align: bottom;
text-align: center;
line-height: 40px;
padding-right: 20px;
text-decoration: none;
}
.facebook:hover {
background: #3a5998;
transition-duration: 0.5s;
-moz-transition-duration: 0.5s;
-webkit-transition-duration: 0.5s;
-o-transition-duration: 0.5s;
transition-timing-function: ease-in;
-moz-transition-timing-function: ease-in;
-webkit-transition-timing-function: ease-in;
-o-transition-timing-function: ease-in;
-webkit-transform:rotate(0deg);
-moz-transform:rotate(0deg);
-o-transform:rotate(0deg);
transform:rotate(0deg);
}
Here is a link to a jsfiddle I created with my problem in it.
(This has my problem without the rest of my website, because I know thats not the problem. I have checked)
If you have any idea on how to fix this, I would greatly appreciate it. Thank you.
use these properties for .facebook
display:block;
text-align:center;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With