如何覆盖父元素的行高

kac*_*pll 0 html css frontend

我在更改子元素的行高时遇到问题.我的目标只是将行高重置为正常值,而不是使用其父级的较高值.

a{ line-height:100px; }
a small{ line-height:10px; //or normal }
Run Code Online (Sandbox Code Playgroud)

所以我希望行高small正常但不起作用.

有任何想法吗?

小演示

Ben*_*ull 5

使用:

small {
  display: inline-block;
  line-height: 1; /*or whatever you like.*/
}
Run Code Online (Sandbox Code Playgroud)

你需要inline-block,因为<small>是内联默认情况下,所以继承其父的行高.