CSS image overlay with color and transparency

前端 未结 5 653
梦谈多话
梦谈多话 2020-12-15 06:33

I am trying to figure out if I can add an overlay to an image like a tint and change the opacity without adding background color. I had no luck so I thought I would ask here

5条回答
  •  一生所求
    2020-12-15 07:26

    JSFiddle Demo

    HTML:

    CSS:

    .image-holder {
        display:inline-block;
        position: relative;
    }
    .image-holder:after {
        content:'';
        top: 0;
        left: 0;
        z-index: 10;
        width: 100%;
        height: 100%;
        display: block;
        position: absolute;
        background: blue;
        opacity: 0.1;
    }
    .image-holder:hover:after {
        opacity: 0;
    }
    

提交回复
热议问题