Combining CSS Pseudo-elements, “:after” the “:last-child”

后端 未结 8 1322
时光说笑
时光说笑 2020-12-22 20:18

I want to make \"grammatically correct\" lists using CSS. This is what I have so far:

The

  • tags are displayed horizontally with commas after t
  • 8条回答
    •  情书的邮戳
      2020-12-22 20:56

      You can combine pseudo-elements! Sorry guys, I figured this one out myself shortly after posting the question. Maybe it's less commonly used because of compatibility issues.

      li:last-child:before { content: "and "; }

      li:last-child:after { content: "."; }

      This works swimmingly. CSS is kind of amazing.

    提交回复
    热议问题