【问题标题】:Why doesn't span display height? [duplicate]为什么不跨越显示高度? [复制]
【发布时间】:2019-03-15 21:37:33
【问题描述】:

在下面的代码中,为什么 span 不遵守高度规则:

<div style="border:1px black solid">
  inside div
  <span style="height:300px">inside span</span>
</div>

http://scratchpad.io/hilarious-shirt-8130

【问题讨论】:

  • 内联元素没有高度
  • 您正在寻找带有内联元素的line-height,或者将其定义为块级amigo。

标签: html css


【解决方案1】:

你必须把下一个样式放到你的 span 标签中

display:inline-block;

如果您想看到更改,请为您的跨度添加背景

background-color: #f00;

【讨论】:

【解决方案2】:

Span 是一个内联元素,它既没有自己的宽度也没有高度。您需要&lt;span style="height:300px; display:inline-block"&gt; 才能使样式高度起作用。

display:inline resets height and width

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-08-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-07-10
    相关资源
    最近更新 更多