【问题标题】:Chrome update affects CSS text-overflow in relation to text-indentChrome 更新会影响与 text-indent 相关的 CSS text-overflow
【发布时间】:2020-01-21 22:23:57
【问题描述】:

在 Chrome 中,带有 text-overflow 的项目的缩进 (text-indent) 版本的行为不再与以前相同。

在 Chrome 版本 77.0.3865.75 之前,缩进文本仍会显示省略号。 I can see that in the changes they've modified the way text-overflow works in the Chromium project.

在 Firefox、Safari 和 Edge 中,缩进的工作方式仍与以前相同(请参阅下面的 Codepens 进行测试)

我的问题:

  1. 关于解决此问题的好方法有什么想法吗?
  2. 对于我自己的教育,这是 Chromium 错误还是其他浏览器未遵循规范?

示例:

鉴于此 HTML:

<div>
  <h1>A long title over a character limit</h1>
  <h1 class="indent">A long title over a character limit</h1>
</div>

还有 CSS:

div {
  width: 25em;
  background: #ccc;
  padding: 1em;
}

h1 {
  max-width: 100%;
  width: 100%;
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
}

h1.indent {
  text-indent: 2em;
}

我们看到在基于 Chromium 的浏览器中,h1.indent 版本的标题没有省略号。

在 Firefox 和其他浏览器中,text-overflow 再次按预期工作。在较新的基于 Chromium 的浏览器中,它没有。 截屏:

以下是 codepen 中 HTML/CSS 的副本: https://codepen.io/camsjams/pen/yLBGBvP

这是一个在 HTML 表格中显示的代码笔: https://codepen.io/camsjams/pen/dybwbWr

【问题讨论】:

    标签: html css google-chrome chromium


    【解决方案1】:

    这是由 Chrome 中的更改引起的,已在 Chromium 开发通道中修复。

    这是我在 Chromium 问题网站上提出的错误:https://bugs.chromium.org/p/chromium/issues/detail?id=1006395#c5

    一旦发布完成,我将使用正确的版本号进行更新。

    更新:在 Chrome 版本 Version 81.0.4044.92 或更高版本中,此错误已修复!

    【讨论】:

      【解决方案2】:

      Chrome 版本 79.0.3945.130(官方构建)(64 位)现在以另一种意想不到的方式运行。

      问题:使用 text-indent、overflow:hidden(需要使用 text-overflow:ellipsis)和 text-overflow:ellipsis 一起根据 text-indent 值将省略号推出可见空间。

      这里是一些基本的 CSS 和 HTML,显示了该行为以及下面的屏幕截图。

      <style>
      	#test1{
      		text-indent:1px;
      	}
      	#test2{
      		text-indent:10px;
      	}
      	.ellipsis{
      		border:1px solid #000;
      		width:200px;
      		margin:50px;
      		overflow:hidden;
      		text-overflow:ellipsis;
      		white-space:nowrap;
      	}
      </style>
      
      <div id="test1" class="ellipsis">
      	Here is some really long text for testing purposes
      </div>
      <div id="test2" class="ellipsis">
      	Here is some really long text for testing purposes
      </div>

      上述版本在 Chrome 中的结果:

      【讨论】:

      • 嗨尼克 - 在 Chrome 版本 Version 81.0.4044.92 或更高版本中,您发布的错误已修复!
      猜你喜欢
      • 1970-01-01
      • 2014-03-04
      • 1970-01-01
      • 2017-08-21
      • 2012-04-08
      • 1970-01-01
      • 2017-01-07
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多