我经历了一种非常奇怪的行为.为什么test2忽略行高,而test1工作正常?(背景颜色只是为了更好地识别容器)
body {
line-height:0.8;
}
.test1 {
background:#fdf;
font-size:24px;
font-family:Arial,sans-serif;
}
.test2 {
background:#ffd;
font:24px Arial,sans-serif;
}
Run Code Online (Sandbox Code Playgroud)
Nie*_*sol 11
font是一种速记属性,使用它可以破坏构成它的任何特定属性.由于line-height包含在font(通常被视为24px/0.8 Arial,sans-serif)中,因此将其重置为其默认值.