Imrul.H
Imrul.H

Reputation: 5870

Show text and icon in the middle of a button

I am coding a button with html5 and css3. Here are how it looks in different sizes:enter image description here

You can see the icons are not in the middle. I know why it happens. But how can I set the icons in middle? Here is my code:

<a href="#" title="" class="blue-pill centered" role="button"><i class="icon">a</i><span>start</span></a>

CSS:

.blue-pill {
  display: block;
  text-decoration: none;
  width: 135px;
  height: 50px;
  margin-bottom: 15px;
  position: relative;
  background-color: #002032;
  border: none;
  color: #FFF;
  text-transform: uppercase;
  font-family: 'Open Sans Condensed', sans-serif;
  font-weight: 700;
  font-size: 14px;
  padding: 0;
  border-radius: 50px;
  cursor: pointer;
  z-index: 2;
  text-align: center;
  line-height: 50px;
  -webkit-box-shadow: 0px 5px 0px #1488ae;
  -moz-box-shadow: 0px 5px 0px #1488ae;
  box-shadow: 0px 5px 0px #1488ae;
}
.blue-pill .icon {
  display: inline-block;
  margin: 0 5px;
  color: #e57125;
  font-size: 20px;
}
.blue-pill span {
  display: inline-block;
}
.blue-pill.centered {
  margin-left: auto;
  margin-right: auto;
}
.blue-pill.inline {
  display: inline-block;
  margin-left: 5px;
  margin-right: 5px;
}

I am using icon fonts for icons. Here is what I want:

enter image description here

Upvotes: 0

Views: 2512

Answers (1)

Pete
Pete

Reputation: 58422

add vertical-align:middle to .blue-pill .icon and .blue-pill span

Example

Upvotes: 2

Related Questions