CSS to select/style first word

后端 未结 11 1921
礼貌的吻别
礼貌的吻别 2020-11-22 13:30

This one has me kind of stumped. I want to make the first word of all the paragraphs in my #content div at 14pt instead of the default for the paragraphs (12pt). Is there a

11条回答
  •  南方客
    南方客 (楼主)
    2020-11-22 14:08

    Sadly even with the likes of CSS 3 we still do not have the likes of :first-word :last-word etc using pure CSS. Thankfully there's almost a JavaScript nowadays for everything which brings me to my recommendation. Using nthEverything and jQuery you can expand from the traditional Pseudo elements.

    Currently the valid Pseudos are:

    • :first-child
    • :first-of-type
    • :only-child
    • :last-child
    • :last-of-type
    • :only-of-type
    • :nth-child
    • :nth-of-type
    • :nth-last-child
    • :nth-last-of-type

    And using nth Everything we can expand this to:

    • ::first-letter
    • ::first-line
    • ::first-word
    • ::last-letter
    • ::last-line
    • ::last-word
    • ::nth-letter
    • ::nth-line
    • ::nth-word
    • ::nth-last-letter
    • ::nth-last-line
    • ::nth-last-word

提交回复
热议问题