【发布时间】:2017-03-24 05:00:49
【问题描述】:
我在努力
p:not(> span)
margin-top 0
margin-bottom 0
line-height 1.2
p
margin-top 0
margin-bottom 0
span
line-height 1.2
和
p:not(span)
margin-top 0
margin-bottom 0
line-height 1.2
p
margin-top 0
margin-bottom 0
span
line-height 1.2
但似乎p 的行高始终为 1.2,即使它有一个子跨度。
<p style="text-align:center"><u>Lunch</u></p>
<p><span style="font-size:0.75em">Spaghetti and Meatballs</span></p>
第一个p 的行高应为1.2,第二个p 的行高应为0。
【问题讨论】:
-
您是否尝试将行高设置为跨度本身?从您的 HTML 示例中,它会做。或者反过来jsfiddle.net/h8wgpuqp
-
您不能根据子元素设置元素的样式,但您可以根据父元素设置子元素的样式
标签: css