开发者

CSS: 62.5% reset not working for line-height only

开发者 https://www.devze.com 2023-03-19 12:36 出处:网络
I\'m using a reset so that ems will be 10x normal pixel sizes. This is working fine for everything EXCEPT line-height. I want to have a h2 line-height of 24px (under normal text sizing) but declaring

I'm using a reset so that ems will be 10x normal pixel sizes. This is working fine for everything EXCEPT line-height. I want to have a h2 line-height of 24px (under normal text sizing) but declaring 2.4em makes it way too big, but 1.5em works. Apparently t开发者_如何转开发he 62.5% rule just isn't applying. Any idea why?

* {
    margin: 0; padding: 0;
}

body {
    font: 62.5% georgia, serif;
}

h2 {
    background: #3418CD; color: #FFFFFF;
    font: bold 1.6em/24px georgia, serif;
    letter-spacing: 2px;
}


When you're using line-height:2.4em that is relative to the font size, so a line height of 2.4em and a font size of 1.6em will be produce a total line height of about 38px.

If you use:

h2 {
    font: bold 1.6em/1.5 georgia, serif;
}

then the line height will be equal to 16px x 1.5, or 24px.

0

精彩评论

暂无评论...
验证码 换一张
取 消