调整em中元素的大小不会随着字体类型而改变,就像它为ex或ch大小改变一样.即使是强硬的不同字体类型也有不同大小的’M’.
Font Serif with em as units
Font Sans-Serif with em as units
Font Serif with ex as units
Font Sans-Serif with ex as units
Font Serif with ch as units
Font Sans-Serif with ch as units
body {
padding: 20px;
}
#em1,#em2 {
width: 25em;
height: 40px;
background: orange;
margin: 20px;
}
#ch1,#ch2 {
width: 50ch;
height: 40px;
background: orange;
margin: 20px;
}
#ex1,#ex2 {
width: 50ex;
height: 40px;
background: orange;
margin: 20px;
}
#em1, #ex1, #ch1{
font-family: Serif;
}
#em2,#ex2,#ch2 {
font-family: Sans-Serif;
}
有关详细信息,请参阅此fiddle.
您可以注意到ch和ex的不同Div大小具有相同的宽度大小但不同的字体类型,但对于em来说则不一样.