Create a lightning bolt design (like The Flash)

后端 未结 9 613
陌清茗
陌清茗 2021-01-29 23:44

\"T-shirt

I am trying to re-create the lightning bolt symbol from The Flash (DC Comics) (or the

9条回答
  •  长发绾君心
    2021-01-30 00:29

    Disclaimer: Use SVG for complex images. We can still have some fun with CSS, though, just use this for learning and not production implementation.

    Is this possible with a single HTML element?

    Yeah! ... with limitations — mainly no border on the bolt... but, hey, minimal HTML!

    • The top and bottom sections are created with the transparent border triangle trick on :before and :after
    • The middle bolt is created with the box-shadow of :before

    Very rough example

    Note: This example uses a

    , as it requires pseudo-element children.

    body {
      background: #F00;
    }
    div {
      height: 300px;
      width: 300px;
      background: #FFF;
      border-radius: 50%;
      border: solid 5px #000;
      margin-top: 200px;
      position: relative;
    }
    div:before,
    div:after {
      content: '';
      position: absolute;
      transform: skewY(-30deg) rotate(20deg);
    }
    div:before {
      border-right: solid 70px yellow;
      border-top: solid 160px transparent;
      box-shadow: 50px 100px yellow;
      left: 50%;
      margin-left: -50px;
      top: -70px;
    }
    div:after {
      border-right: solid 70px transparent;
      border-top: solid 160px yellow;
      bottom: -30px;
      left: 100px;
    }

提交回复
热议问题