CSS z-index paradox flower

后端 未结 6 521
遇见更好的自我
遇见更好的自我 2021-01-29 20:20

I would like to create a paradoxical effect via the z-index CSS property.

In my code I have five circles, like in the image below, and they are all absolute

6条回答
  •  独厮守ぢ
    2021-01-29 20:55

    Here's my go at it.

    I also use a pseudo element positioned on top of the first circle, but rather than using clip, I keep its background transparent and just give it an inset box-shadow that matches the background color of the circles (silver) as well as a red border to cover the bottom right sides of the circle's border.

    Demo

    CSS (that is different from starting point)

    .i1 { 
      position: absolute; top: 30px; left: 0px;
      &:before {
        content: '';
        position: absolute;
        z-index: 100;
        top: 0;
        left: 0;
        width: 50px;
        height: 50px;
        border-radius:  50%;
        box-shadow: inset 5px -5px 0 6px silver;
        border-bottom: solid 1px red;
      }
    }
    

    Final product enter image description here

提交回复
热议问题