CSS z-index paradox flower

后端 未结 6 472
遇见更好的自我
遇见更好的自我 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 21:14

    Sadly the following is just a theoretical answer, as for some reason I can't get -webkit-transform-style: preserve-3d; to work (have to be making some obvious mistake, but can't seem to figure it out). Either way, after reading your question I - as with every paradox - wondered why it's only an apparent impossibility, rather than a real one. Another few seconds me realize that in real life the leaves are rotated a bit, thus allowing such a thing to exist. So then I wanted to concoct a simple demonstration of the technique, but without the previous property that's impossible (it gets drawn to the flat parent layer). Either way, here is the base code none the less

    1
    2
    3
    4
    5

    And the css:

    .i1 {
        -webkit-transform:rotateZ(288deg)
    }
    .i2 {
        -webkit-transform:rotateZ(0deg)
    }
    .i3 {
        -webkit-transform:rotateZ(72deg)
    }
    .i4 {
        -webkit-transform:rotateZ(144deg)
    }
    .i5 {
        -webkit-transform:rotateZ(216deg)
    }
    .leaf { 
        position:absolute;
        left:35px;
        top:35px;
    }
    .leaf > .item {
        -webkit-transform:rotateY(30deg) translateY(35px)
    }
    

    And you can find the full code here.

提交回复
热议问题