Вы должны дать видео display: block;
стиль
video {
/* video has a default display of inline */
display: block;
}
<div style="background-color:#B9CFBB" align="middle">
<video width="360" height="240" controls>
<source src="xxxxxx">
Your browser does not support the video tag.
</video>
</div>
Это связано с тем, что встроенный элемент отображается в соответствии с окружающим текстовым содержимым.В этом случае он может быть пустым, но он имеет высоту строки: поскольку по умолчанию vertical-align
из video
равно baseline
, спусковым механизмам также необходимо место.Вот откуда брешь.
Вы также можете изменить вертикальное выравнивание видео, как показано ниже (я добавил текст, чтобы продемонстрировать проблему.), Чтобы решить проблему.
div {
text-align: center;
}
video {
/* video has a default display of inline */
display: inline;
}
#two video {
/* video has a default vertical-align of baseline */
vertical-align: text-top;
}
#three video {
vertical-align: -3em;
}
<div id="one" style="background-color:#B9CFBB">
fghpq before <video width="360" height="240" controls>
<source src="xxxxxx">
Your browser does not support the video tag.
</video> after fghpq
</div>
<div id="two" style="background-color:#F9CFBB">
fghpq before <video width="360" height="240" controls>
<source src="xxxxxx">
Your browser does not support the video tag.
</video> after fghpq
</div>
<div id="three" style="background-color:#B9CFFB">
fghpq before <video width="360" height="240" controls>
<source src="xxxxxx">
Your browser does not support the video tag.
</video> after fghpq
</div>