html - 文本溢出省略号不适用于标题标签

标签 html css

为什么标题标签溢出时不显示省略号?如何显示 header 标签的省略号?

div {
    width: 200px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
<div>
   <h4>Ellipsis does not work with header tags</h4>
   <span>Ellipsis does work with span tags</span>
</div>

最佳答案

尝试添加

h4 {
    display: inline;
}

你会看到它按预期工作

div {
    width: 200px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

h4 {
    display: inline;
}
<div>
   <h4>Ellipsis does not work with header tags</h4> <br>
   <span>Ellipsis does work with span tags</span>
</div>

关于html - 文本溢出省略号不适用于标题标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59453025/

相关文章:

html - bootstrap 3.1 在移动时首先拉取主要内容(在顶部)

html - Bootstrap 表单与上面的标签内联,位置按钮

javascript - 如何创建隐藏菜单?

javascript - Bootstrap 开关未切换

html - CSS3 Hover 不适用于更改 Button 图像

javascript - 将数据插入工作表并发送电子邮件

html - 偏移 html anchor 以使用网格调整固定标题

jquery - 如何防止随机 jquery 切换?

html - "margin-top:auto"不工作

c# - 显示无/删除样式背后的asp.net 代码不起作用