How to center HTML5 Videos?

后端 未结 15 1813
终归单人心
终归单人心 2021-01-31 02:25

I\'m just messing around with some HTML5, and I was trying to center a video on the page. For some reason I can\'t get it to center. I\'ve tried to add a class to the video tag

15条回答
  •  猫巷女王i
    2021-01-31 02:38

    I will not prefer to center just using video tag as @user142019 says. I will prefer doing it like this:

    .videoDiv
    {
        width: 70%; /*or whatever % you prefer*/
        margin: 0 auto;
        display: block;
    }

    This will make your video responsive at the same time the panel for controls will have the same size as the video rectangle (I tried what @user142019 says and the video was centered, but it looked ugly in Google Chrome).

提交回复
热议问题