Gradient over img tag using css

后端 未结 4 1337
孤独总比滥情好
孤独总比滥情好 2020-12-31 00:42

I want to place a gradient over an tag. src attribute of the tag is angular-item. For example:

4条回答
  •  爱一瞬间的悲伤
    2020-12-31 00:57

    For 2020, mask-image can work well. It works in modern browsers (not IE, -webkit- prefix in many browsers currently). https://caniuse.com/#feat=css-masks

    img {
       height: 200px;
       width: auto;
       mask-image: linear-gradient(to bottom, rgba(0,0,0,0) 0%,rgba(0,0,0,0.65) 100%);
       -webkit-mask-image: linear-gradient(to bottom, rgba(0,0,0,0) 0%,rgba(0,0,0,0.65) 100%);
    }
       

提交回复
热议问题