Reputation: 121
* {
margin: 0;
padding: 0;
}
div {
line-height: 30px;
}
a {
font-size: 12px;
}
<div>
<a href="">测试</a>
</div>
I believe the content height is the same as line-height
which is 30px
. But actually in Chrome, it's 32px
. Why is that?
Upvotes: 4
Views: 2649
Reputation: 4433
Because the line-height
depends in font-size
Check this jsfiddle i just changed the font-size
and the height is 30px
also you need vertical-align: middle;
for the <a>
so the space from top and bottom to be equal
Upvotes: 1
Reputation: 412
Because <a />
has it's own line height, which is above 1.0.
Add this line in CSS:
a {
/* current styles */
line-height: 1;
}
http://codepen.io/anon/pen/KrERPP
Upvotes: 3