【问题标题】:::after pseudo-element not appearing on Chrome Mobile::after 伪元素未出现在 Chrome 移动设备上
【发布时间】:2018-04-19 11:14:57
【问题描述】:

非常简单但奇怪的错误,我有一个伪元素,它在桌面浏览器上看起来很好,但在移动 Chrome 上消失了(不确定 iOS,没有 iPhone 可以测试)

这是基本的 CSS:

a {
  text-decoration: none;
  display: inline-block;
  color: #000;
  overflow: visible;
}

a::after {
  content: '';
  display: block;
  height: 8px;
  width: 98%;
  background: #8BC8F690;
  margin-top: -9px;
  margin-left: 2px;
}
<a>hello</a>

jsfiddle: https://jsfiddle.net/w4d1jteb/

【问题讨论】:

标签: html css google-chrome web


【解决方案1】:

检查您的background。这不是一个有效值。它有 8 个字符长,但只能有 6 个。

a {
  text-decoration: none;
  display: inline-block;
  color: #000;
  overflow: visible;
}

a::after {
  content: '';
  display: block;
  height: 8px;
  width: 98%;
  background: #8BC8F690; <-- This is not valid. *1*2
  margin-top: -9px;
  margin-left: 2px;
}

*1: 你可以试试background-color: rgba(139, 200, 246, 0.565)

*2:或者直接使用#8BC8F6

请参阅以下示例:

a {
  text-decoration: none;
  display: inline-block;
  color: #000;
  overflow: visible;
}

a::after {
  content: '';
  display: block;
  height: 8px;
  width: 98%;
  background-color: rgba(139, 200, 246, 0.565);
  margin-top: -9px;
  margin-left: 2px;
}

#test {
  text-decoration: none;
  display: inline-block;
  color: #000;
  overflow: visible;
}

#test::after {
  content: '';
  display: block;
  height: 8px;
  width: 98%;
  background: #8BC8F6;
  margin-top: -9px;
  margin-left: 2px;
}
<a>hello</a>

<a id="test">hello2</a>

【讨论】:

  • 正确,这是我调试问题时的截图:i.stack.imgur.com/WWJO1.png
  • 哦,谢谢!完全忘记了我正在尝试 alpha 值,但实际上并没有查找它。我的错。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2016-08-01
  • 2018-02-25
  • 1970-01-01
  • 1970-01-01
  • 2021-12-27
  • 2022-12-10
  • 2020-11-09
相关资源
最近更新 更多