Why em instead of px?

后端 未结 15 1274
闹比i
闹比i 2020-11-22 06:38

I heard you should define sizes and distances in your stylesheet with em instead of in pixels. So the question is why should I use em instead of px when defining styles in c

15条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-11-22 07:20

    The main reason for using em or percentages is to allow the user to change the text size without breaking the design. If you design with fonts specified in px, they do not change size (in IE 6 and others) if the user chooses text size - larger. This is very bad for users with visual handicaps.

    For several examples of and articles on designs like this (there are a myriad to choose from), see the latest issue of A List Apart: Fluid Grids, the older article How to Size Text in CSS or Dan Cederholm's Bulletproof Web Design.

    Your images should still be displayed with px sizes, but, in general, it is not considered good form to size your text with px.

    As much as I personally despise IE6, it is currently the only browser approved for the bulk of the users in our Fortune 200 company.

提交回复
热议问题