Transparent text cut out of background

后端 未结 12 684
无人及你
无人及你 2020-11-22 06:05

Is there any way to make a transparent text cut out of a background effect like the one in the following image, with CSS?
It would be sad to lose all pr

12条回答
  •  有刺的猬
    2020-11-22 06:35

    I just discovered a new way to do this while messing around, I'm not entirely sure how it works ( if someone else wants to explain please do ).

    It seems to work very well, and requires no double backgrounds or JavaScript.

    Here's the code: JSFIDDLE

    body {
      padding: 0;
      margin: 0;
    }
    
    div {
      background: url(http://www.color-hex.com/palettes/26323.png) repeat;
      width: 100vw;
      height: 100vh;
    }
    
    body::before {
      content: '$ALPHABET';
      left: 0;
      top: 0;
      position: absolute;
      color: #222;
      background-color: #fff;
      padding: 1rem;
      font-family: Arial;
      z-index: 1;
      mix-blend-mode: screen;
      font-weight: 800;
      font-size: 3rem;
      letter-spacing: 1rem;
    }

提交回复
热议问题