问题描述
这是我的代码:
div {
border: thin solid gray;
display: inline-block;
}
h1 {
background: lightblue;
}
span {
background: orange;
}
.b h1 {
line-height: 1.2em;
}
.c span {
font-size: 0.5em;
}
.d h1 {
line-height: 1.2em;
}
.d span {
font-size: 0.5em;
}
<div class="a"><h1>Foo<span>Bar</span></h2></div>
<div class="b"><h1>Foo<span>Bar</span></h2></div>
<div class="c"><h1>Foo<span>Bar</span></h2></div>
<div class="d"><h1>Foo<span>Bar</span></h2></div>
有四个 div
。每个 div
都有一个 h1
和一个 span
嵌套在 h1
中。只有 line-height
和 font-size
样式与此问题相关。其他样式仅用于可视化问题。这是要重点关注的内容,
-
div.a
是一个普通的 div。此处没有line-height
或font-size
样式。 -
div.b
仅样式h1
具有line-height: 1.2
。 -
div.c
仅样式span
具有font-size: small
。 -
div.d
使h1
具有line-height: 1.2
和span
具有font-size: small
。
为什么 div.d
中的标题比其他标题的高度大?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)