Html5 video background, keep center of video in center

后端 未结 10 1411
爱一瞬间的悲伤
爱一瞬间的悲伤 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条回答
  •  旧时难觅i
    2020-12-23 12:33

    So I tested above solutions and couldn't find that one, so here is mine:

    video {
          position: fixed;
          left: 50%;
          top: 50%;
          min-width: 100%;
          min-height: 100%;
          transform: translate(50%, -50%);
    }
    

提交回复
热议问题