What is the logic behind sibling selectors * + * and * ~ *?

前端 未结 3 931
难免孤独
难免孤独 2020-12-30 23:56

For this question I\'m using the following markup:


    

1

3条回答
  •  醉梦人生
    2020-12-31 00:34

    They are not applied to the first paragraph actually. To demonstrate this, let's change the stylesheet a bit:

    * + *    { border-right: solid red }
    * ~ *    { border-left: solid black; }
    

    demo

    fiddle

    They are both applied to the "body" element which is in fact preceded by "head".

提交回复
热议问题