Transparent half circle cut out of a div

前端 未结 8 2449
一生所求
一生所求 2020-11-22 05:34

I would like to make a transparent cut out half circle shape using only CSS3. The only requirement is that all the elements that form the shape must

8条回答
  •  余生分开走
    2020-11-22 05:36

    You can do it really easily with a radial gradient.

    DEMO

    Result:

    shape

    HTML:

    Relevant CSS:

    .shape {
      margin: 0 auto;
      width: 10em; height: 16em;
      /* WebKit browsers, old syntax */
      background: -webkit-radial-gradient(50% 0, circle, transparent 30%, black 30%);
      
      /* IE10, current versions of Firefox and Opera */
      background: radial-gradient(circle at 50% 0, transparent 30%, black 30%);
    }
    

    See http://caniuse.com/#feat=css-gradients for detailed info on compatibility.

提交回复
热议问题