Search code examples
csscss-shapes

CSS3 moon shape


I am trying to create a button like this:

enter image description here

I dont know how to create a light moon shape over the top of the button.

This is still far off: Fiddle Demo.

.moon {
   width: 50px;
   height: 50px;
   border-radius: 50%;
   box-shadow: 15px 15px 0 0 green;
}

Solution

  • With just a little inset you can style the shadow on top of the object.

    E.g. Crescent shape.

    And, This is the button you want.

    .moon {
      background-color: #222;
      width: 50px;
      height: 50px;
      border-radius: 50%;
      border: 4px solid #222;
      /* I set 2 shadows where the first one doesn't have blur and spread for firefox fix. */
      box-shadow: inset 0px 16px #999, inset 0px 16px 1px 1px #999;
      -moz-box-shadow: inset 0px 16px #999, inset 0px 16px 1px 1px #999;
    }
    <div class="moon"></div>