How to center HTML5 Videos?

后端 未结 15 1983
终归单人心
终归单人心 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条回答
  •  爱一瞬间的悲伤
    2021-01-31 02:54

    @snowBlind In the first example you gave, your style rules should go in a

    Also, I tried the changes that were mentioned in this answer (see results at http://jsfiddle.net/8cXqQ/7/), but they still don't appear to work.

    You can surround the video with a div and apply width and auto margins to the div to center the video (along with specifying width attribute for video, see results at http://jsfiddle.net/8cXqQ/9/).

    But that doesn't seem like the simplest solution...shouldn't we be able to center a video without having to wrap it in a container div?

提交回复
热议问题