CSS 伪选择不改变 text-shadow 属性

标签 css css-selectors

每当我在 ::selection/::-moz-selection 中使用 text-shadow: none; 时,它就不会工作。

我只是很困惑为什么它在网站上有效 12但不在我下面的代码中。 This code 正是我想要的,但它在我自己的代码中不起作用。

我的代码

textarea {
  background: #778899;
  color: #FFFFFF;
  text-shadow: 0 0 5px #000000;
  font-size: 50px;
}
.fortext::-moz-selection {
  background: #FFFFFF;
  color: #000000;
  text-shadow: none;
}
.fortext::selection {
  background: #FFFFFF;
  color: #000000;
  text-shadow: none;
}
<textarea class="fortext">Test</textarea>

What I get

上面是我得到的,你可以看到阴影仍然存在。

我尝试过的:

文本阴影:

  • 0 0 0 #000
  • 0 0 0 无
  • 0 0 0 清除
  • 清除
  • 0px 0px 0px 无
  • 5px 5px 5px 无

以上代码都没有改变任何内容。

我也看到了this发帖了,但是好像没用。

最佳答案

Chrome 在处理文本区域时失败。对于 p 来说效果很好。 这就是您链接的示例有效的原因

p {
  background: #778899;
  color: #FFFFFF;
  text-shadow: 0 0 5px #000000;
  font-size: 50px;
}
.fortext::-moz-selection {
  background: #FFFFFF;
  color: #000000;
  text-shadow: none;
}
.fortext::selection {
  background: #FFFFFF;
  color: #000000;
  text-shadow: none;
}
<p class="fortext">Test</p>

关于CSS 伪选择不改变 text-shadow 属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34011604/

相关文章:

javascript - IE7 : li's behaving badly

css - 是否有 CSS 父级选择器?

祖先类型的第一个后代的 CSS 选择器

css - 选择图片的 alt 属性

html - CSS 内置内容不工作

html - 使用 css chrome 和 firefox 的滚动样式

php - 哪种方法对于大写文本 : CSS or PHP? 更有效

html - 使用 :not(selector) 选择除少数元素之外的所有元素

javascript - 如何让几个网页在移动设备上显示不同

css - 如何使 iFrame 随背景滚动?