CSS z-index paradox flower

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

    JS Fiddle LIVE DEMO

    Works on IE8 too.

    HTML

    1
    1
    2
    3
    4
    5

    CSS

    .item {
        width: 50px;
        height: 50px;
        line-height: 50px;
        border: 1px solid red;
        background: silver;
        border-radius: 50%;
        text-align: center;
    }
    .half {
        position: absolute;
        overflow: hidden;
        width: 52px;
        height: 26px;
        line-height: 52px;
        text-align: center;
    }
    .half.under {
        top: 30px; 
        left: 0px;
        z-index: -1;
        border-radius: 90px 90px 0 0;
    }
    .half.above {
        top: 55px;
        left: 0px;
        z-index: 1;
        border-radius: 0 0 90px 90px;
    }
    .half.above .i1 { margin-top:-50%; }
    .i2 { position: absolute; top: 0px; left: 35px;}
    .i3 { position: absolute; top: 30px; left: 65px;}
    .i4 { position: absolute; top: 70px; left: 50px; }
    .i5 { position: absolute; top: 70px; left: 15px; }
    

提交回复
热议问题