Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Icon font - icon height bigger than expected

Tags:

css

fonts

glyph

I'm using an icon font generated by fontastic.me in my project. However, all icons are a little bit higher as expected.

Snippet here:

.icon-camera {
  font-size: 40px;
  background: #ff0000;
}
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>JS Bin</title>
  <link href="https://fontastic.s3.amazonaws.com/FsVBbT8KX9p5tE8xXk4xmE/icons.css" rel="stylesheet">
</head>
<body>
  <span class="icon-camera"></span>
</body>
</html>

What can cause this effect, and how can I get rid of it?

like image 373
Tamás Pap Avatar asked Sep 27 '14 14:09

Tamás Pap


1 Answers

Font Awesome has developed a solution to deal with this issue. I mirrored their solution by creating a new class called ".icon" in my font.css file. It seems to work well with Fontastic too.(Make sure you add your font where I have "your-icon-font-here").

.icon {
    display: inline-block;
    font: normal normal normal 14px/1 "your-icon-font-here";
    font-size: inherit;
 }

<i class="icon icon-tag"></i>
like image 50
Andrew Dotson Avatar answered Oct 22 '22 01:10

Andrew Dotson