【问题标题】:How to influence the start of a folded <span> line?如何影响折叠 <span> 行的开始?
【发布时间】:2018-10-03 19:33:19
【问题描述】:

我有一个由三个&lt;span&gt; 组成的文本,但我不明白折叠它们时应用的规则:

<span style="font-family: sans-serif; 
font-weight: normal; 
color: black; 
background-color: white; 
border-color: darkblue; 
border-style: solid; 
border-width: 5px; 
padding: 3px 3px 3px 7px;
text-align: center;
">
    ℹ
</span>
<span style="
font-family: sans-serif; 
font-weight: bold;
color: white; 
background-color: darkblue;
border-color: darkblue;
border-style: solid;
border-width: 5px;
padding: 3px 3px 3px 3px;
">
    This is some text
</span>
<span style="font-family: sans-serif; 
font-weight: normal; 
color: black; 
background-color: white; 
border-color: darkblue; 
border-style: solid; 
border-width: 5px; 
padding: 3px 5px 3px 5px;
">
    This is more text, a longer one which will eventually fold. Some more words.
</span>

如果缩小浏览器的宽度,则消息会折叠并与上部重叠。

折叠是如何计算的?(决定将文本放置在特定距离时要考虑什么?)

因此:影响到下一行文本底部移动的参数是什么?(换句话说:要改变什么以使第二行开始更低)

【问题讨论】:

    标签: html css


    【解决方案1】:

    调整line-height。来自specification

    内联非替换框的垂直内边距、边框和边距 从内容区的顶部和底部开始,和无关 与“线高”。 但在时只使用'line-height' 计算线框的高度

    span {
      font-family: sans-serif;
      border-color: darkblue;
      border-style: solid;
      border-width: 5px;
    }
    <span style=" font-weight: normal; 
    color: black; 
    background-color: white; 
    padding: 3px 3px 3px 7px;
    text-align: center;">
        ℹ
    </span>
    <span style="
    font-weight: bold;
    color: white; 
    background-color: darkblue;
    padding: 3px 3px 3px 3px;
    ">
        This is some text
    </span>
    <span style=" 
    font-weight: normal; 
    color: black; 
    background-color: white; 
    padding: 3px 5px 3px 5px;
    line-height:35px;
    ">
        This is more text, a longer one which will eventually fold. Some more words.
    </span>

    【讨论】:

    • 谢谢。您将line-height:35px; 仅应用于最后一部分是否有特殊原因? (或者仅仅是因为预计这是唯一一个会弃牌的人)
    • @WoJ 你可以申请任何一个 :) 它会是一样的。或者您也可以将其应用于他们的容器(在这种情况下为主体),它也将是相同的。这有点棘手,但为了简单的解释,就像我们考虑最大行高来找到行框的高度(实际上比这更复杂)
    • @WoJ 您可以在深度解释中查看更多信息:stackoverflow.com/questions/52282391/…
    猜你喜欢
    • 1970-01-01
    • 2019-11-14
    • 1970-01-01
    • 2011-12-18
    • 2019-11-18
    • 1970-01-01
    • 1970-01-01
    • 2021-12-10
    • 1970-01-01
    相关资源
    最近更新 更多