Using CSS, can you apply a gradient mask to fade to the background over text?

后端 未结 4 1498
攒了一身酷
攒了一身酷 2020-11-30 01:55

I have a full screen fixed background image. I would like the text in my scrolling div to fade out at the top, presumably by applying a gradient mask to the background at on

4条回答
  •  日久生厌
    2020-11-30 02:17

    If you're fading to a solid color, you can use a psudo element:

    .image-container {
        position: relative;
        display: inline-block;
      }
    
    .image-container:after {
      content: "";
      display: block;
      position: absolute;
      width: 100%;
      height: 55%;
      bottom: 0;
      background: -webkit-linear-gradient(transparent, #FFF) left repeat;
      background: linear-gradient(transparent, #FFF) left repeat; 
    }
    don't shoot me

提交回复
热议问题