:第一封信不与强者合作

sim*_*ple 7 html css

我放弃.为什么:第一封信不在这里工作?

strong {
  font-weight: bold;
  color: blue;
}
strong:first-letter {
  color: red;
}

<strong>test test</strong>
Run Code Online (Sandbox Code Playgroud)

Dav*_*mas 9

除了其他答案之外,它(至少在Chromium中)也可以使用元素display: inline-block,因此display只需要除了inline(包括list-item)以外的任何东西,例如:

strong {
    font-weight: bold;
    color: blue;
    display: inline-block;
}
strong::first-letter {
    color: red;
}
Run Code Online (Sandbox Code Playgroud)

JS小提琴演示.

此外,::first-letter是一个伪元素,因此语法应该是双冒号而不是单个,以区分选择器和伪类.


tym*_*eJV 5

first-letter 不适用于内联元素,仅适用于块元素.