为什么 text-align: center 在视频上起作用?
Why does text-align: center work on videos?
所以我搞乱了 CSS(只是为了好玩而随机添加一些东西,即使我认为它们不会做任何事情)我把 text-align: center;
放在 <div>
上并将 <video>
居中。
有人可以向我解释为什么这样做吗?
<div style="text-align: center">
<video width="400" controls>
<source src="https://www.w3schools.com/html/mov_bbb.mp4" type="video/mp4">
<source src="https://www.w3schools.com/html/mov_bbb.ogg" type="video/ogg">
Your browser does not support HTML video.
</video>
</div>
The element is a replaced element — its display value is inline by default, but its default width and height in the viewport is defined by the video being embedded. ref
和text-align
影响行内元素。 img
、canvas
和 iframe
相同
所以我搞乱了 CSS(只是为了好玩而随机添加一些东西,即使我认为它们不会做任何事情)我把 text-align: center;
放在 <div>
上并将 <video>
居中。
有人可以向我解释为什么这样做吗?
<div style="text-align: center">
<video width="400" controls>
<source src="https://www.w3schools.com/html/mov_bbb.mp4" type="video/mp4">
<source src="https://www.w3schools.com/html/mov_bbb.ogg" type="video/ogg">
Your browser does not support HTML video.
</video>
</div>
The element is a replaced element — its display value is inline by default, but its default width and height in the viewport is defined by the video being embedded. ref
和text-align
影响行内元素。 img
、canvas
和 iframe