html - overflow-x 跨度内的文本溢出

标签 html css

 .whysolong {
    overflow-x: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

放入div

<div class="whysolong">So many people here but only 3 or four global apps grow UP?</div>

好的!

这么多人....

span

<span class="whysolong">So many people here but only 3 or four global apps grow UP?</span>

Still showing full text..

这里这么多人,但只有三四个全局应用成长起来了?

为什么?

最佳答案

文本溢出只能发生在 block 级或行内 block 级元素上,因为元素需要有宽度才能溢出。溢出发生在由 direction property 确定的方向上或相关属性。

 .whysolong {
  overflow-x: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  width: 154px;
}

 .whysolongblock {
  overflow-x: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  width: 154px;
  display: block;
}
<div class="whysolong">So many people here but only 3 or four global apps grow UP?</div>
<span class="whysolong">So many people here but only 3 or four global apps grow UP?</span>
<div class="whysolongblock">So many people here but only 3 or four global apps grow UP?</div>
<span class="whysolongblock">So many people here but only 3 or four global apps grow UP?</span>

注意 text-overflow 仅当容器的 overflow 属性的值为 hiddenscrollautowhite-space: nowrap;

关于html - overflow-x 跨度内的文本溢出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41126157/

相关文章:

javascript - 使一个 div 贴在屏幕顶部,但如果向上滚动,返回到它的原始位置?

html - Top in position relative 没有按预期工作

javascript - 多数据系列c3图表中默认仅选择部分数据

python - 使用 Python BeautifulSoup 库解析 Span HTML 标签中的信息

html - 如何使用 vw 单位在 css 中创建响应圈?

css - 滚动条导致底部填充

html - 如何创建从中间到边缘导航栏选定标记的边框?

html - 使用 css 禁用超链接

javascript - XSLT 在 IF 语句后添加书价

html - 在容器底部堆叠 HTML 元素