0

I've got an icon within a link tag and I'm trying to make it circular, but it fits to the content rather than being set by my width and height settings. Here's what I mean: https://i.stack.imgur.com/BMlMQ.png

My code is like this:

html:

<div class="small-4 columns switchButton">
    <a href="#">
        <i class="icon-bolt"></i>
    </a>
</div>

And my CSS is like this:

.switchButton
    text-align: center
    margin: 60px 0 60px 0
.switchButton a
    text-decoration: none
    width: 80px
    height: 80px
    font-size: 40px
    padding: 20px
    -moz-border-radius: 40px
    -webkit-border-radius: 40px
    border-radius: 40px

The icon is by font-awesome and has the following CSS:

a [class^="icon-"], a [class*=" icon-"] {
display: inline;
}
[class^="icon-"], [class*=" icon-"] {
display: inline;
width: auto;
height: auto;
line-height: normal;
vertical-align: baseline;
background-image: none;
background-position: 0% 0%;
background-repeat: repeat;
margin-top: 0;
}
[class^="icon-"], [class*=" icon-"] {
font-family: FontAwesome;
font-weight: normal;
font-style: normal;
text-decoration: inherit;
-webkit-font-smoothing: antialiased;

So, even though the width and height are set, it still fits to the icon. Any ideas?

Relevant JSFiddle: http://jsfiddle.net/babaggeii/QZSwn/2/ - you can see that the a tag fits the text rather than the dimensions specified.

babbaggeii
  • 7,577
  • 20
  • 64
  • 118

1 Answers1

1

Looks like isn't your a — it has 60px x 87px and does not correspond with what you put in CSS.

Try this:

.switchButton a {
    text-decoration: none;
    width: 80px;
    height: 80px;
    background-color: #666;
    color: #fff;
    font-size: 40px;
    -moz-border-radius: 40px;
    -webkit-border-radius: 40px;
    border-radius: 40px;

    /** My CSS **/
    display: block; /* The element is displayed as a block-level element (like paragraphs and headers) */
    line-height: 80px; /* To determine the height of your line */
    text-align: center; /* To centralize the text horizontally */
}

I have illustrated the code above on JSFiddle.

Hope it helps.

Guilherme Oderdenge
  • 4,935
  • 6
  • 61
  • 96