Home >Web Front-end >CSS Tutorial >em px relationship_experience exchange

em px relationship_experience exchange

WBOY
WBOYOriginal
2016-05-16 12:09:161403browse

The situation is like this. There are two commonly used units for defining font size in CSS: em and px.

em is a relative number. For example, 1.1em means 1.1 character width, and this character width is initialized based on font-size. At the same time, em also inherits the characteristics of the parent object, so 1.2em at different positions are not necessarily equal, but this article has nothing to do with this and I won’t go into details.
px is for the resolution of the current display device. Although there will still be size differences for different devices, it is relatively more suitable for defining fonts.
I did not specifically define the font size of the search part in this template, so it used the font-size parameter 12px of the parent object. The damn IE definition of font size is actually different from FF/Opera. By default, 1em looks larger in IE than other browsers, so you need to add the following definition to the body part:

Copy code The code is as follows:

font-size:62.5%;
font-family:'Lucida Grande', Verdana, Arial, Sans-Serif;

The key is the first sentence, which makes the font size under IE look like: 1em=10px, which is almost the same as FF/Opera.
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn