css - Firefox 未将样式应用到 "first-child:first-letter"

标签 css firefox css-selectors

我正在尝试将某种样式应用于标题中的第一个字母,该字母由文本组成。我的网页在这里:http://smarterinfive.com

它在 Chrome 中运行良好,但在 FF 中完全无效。以下是我已经尝试应用我的样式但无济于事的属性(在 FF 中):

header[role="banner"] .branding:first-letter {
background: #000;
}

.branding:first-child:first-letter {
background: #000;
 }

.branding h1 a:first-child:first-letter {
background: #000;
}

似乎所有带有 first-letterfirst-child:first-letter 的东西都不起作用,但是所有带有 first-child 的东西都不起作用> 只有是。

我也试过:

  1. 在这些末尾添加 !important
  2. 在开发者工具中查看它,根本没有显示该属性。

最佳答案

.branding h1 a:first-child:first-letter 的问题是 first-letter 只能应用于 block 元素,而不是内联元素,如 一个。看这个previous question

我也不明白为什么其他人不工作...

但为什么您甚至需要使用 first-child

你可以得到相同的效果并解决这个问题:

.branding h1:first-letter {
  background: black;
}

其实更简单。

Demo

关于css - Firefox 未将样式应用到 "first-child:first-letter",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15845533/

相关文章:

google-chrome - google chrome 和 firefox 缓存 DNS 记录多长时间

css - 多个 nth-last-child 和/或 last-child 不工作

css - div 中的样式表单元素

html - 如何调整大于 div 容器的图像以完全适合它(自动调整大小、缩小等...)

css - 用什么? "vertical-align:top"或 "vertical-align:text-top"

html - Firefox adblock 阻止了我的 CSS 样式

html - Firefox 在 Aptana 中看不到 CSS/HTML 链接

jquery - CSS 和 jQuery 中的选择器有什么区别?

jquery - Slick vs. Sizzle——CSS 选择器引擎的优缺点

javascript 和 css 过渡属性不适用于 firefox