Html5 video background, keep center of video in center

后端 未结 10 1444
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-23 12:00

I am trying to keep a background video centered regardless of how big the user drags the video. It\'s currently cutting off the right side of the videos when i scroll smalle

10条回答
  •  长情又很酷
    2020-12-23 12:28

    This is much shorter and worked for me.

    video {
        position: fixed;
        right: 0;
        bottom: 0;
        min-width: 100%;
        min-height: 100%;
        transform: translateX(calc((100% - 100vw) / 2));
    }
    

提交回复
热议问题