body{ font-size: 62....">

Why does the font size not change?

I want to set the font size using em , not px . Here is my code:

 <style type="text/css"> body{ font-size: 62.5%; } div{ font-size: 1.2em; } </style> <body> <div>hello world</div> </body> 

I want to set the font size of the div to 12px, but it looks small than I expect, I will disable the div style using the Chrome browser tools, it will not have any changes. Why and how to do to make a div font size 12px? Thanks.

+7
source share
1 answer

hmm seems to work for me: example

Although, what you can refer to is a small change from enabling / disabling the font-size property. This is because em for nested elements refers to the font-size parents. In your case, font-size:Xem for a div refers to the body of font-size:X% .

If you still haven't changed, try setting the body font-size to a larger percentage to increase the div font

+6
source

All Articles