Overlaying a transparent background on an embedded video

前端 未结 2 1570
面向向阳花
面向向阳花 2021-01-18 02:45

I\'ve a video which I\'ve embedded in a fullwidth div panel. I\'m trying to overlay a gradient on top of it, but I can\'t make it work. I\'ve tried adjusting z-index, wrappi

2条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-01-18 03:28

    Here is a fiddle

    I used green overlay for the demo.

    CSS

    .videoContainer {
        position: relative;
        width: 100%;
        height: 100%;
        //padding: 20px;
        border-radius: 5px;
        background-attachment: scroll;
        overflow: hidden;
    }
    .videoContainer video {
        min-width: 100%;
        min-height: 100%;
        position: relative;
        z-index: 1;
    }
    .videoContainer .overlay {
        height: 100%;
        width: 100%;
        position: absolute;
        top: 0px;
        left: 0px;
        z-index: 2;
        background: green;
        opacity: 0.5;
    }
    

提交回复
热议问题