html - 为什么我的视频没有垂直对齐(flexbox)?
问题描述
我希望有人能启发我为什么我的视频一直漂浮在顶部而不是垂直对齐?我正在使用弹性盒。
`.mainLogoAnimation{
position: relative;
display: flex;
justify-content: center;
align-content: center;
width: 100%;
height: 100%;
}
video{width: 100%;
}
<body>
<div class="mainLogoAnimation">
<a href="indexPage2.html"><video src="samples/Audio Branding - Arcade/ArcadeLogo_Stinger_03.mp4" id="javaPlayer" autoplay loop muted></video> </a>
</div>
</body>
解决方案
- 使用
align-items: center
. - 将和元素的 设置为 100%
height
。html
body
.mainLogoAnimation {
position: relative;
display: flex;
justify-content: center;
align-items: center;
width: 100%;
height: 100%;
}
html, body {
height: 100%;
margin: 0;
}
video {
width: 100%;
}
<div class="mainLogoAnimation">
<a href="indexPage2.html"><video src="https://www.w3schools.com/tags/movie.mp4" id="javaPlayer" autoplay loop muted></video> </a>
</div>
推荐阅读
- cypress - 我收到 cypress 错误“TypeError 无法读取未定义的属性‘数据’”
- opencv - 对 AKAZE 参数有什么解释吗?
- python - 带有用户输入和自定义按钮的 Tkinter 对话框
- php - 如何使用事件侦听器向用户显示警报消息
- r - 如何在 r 中使用列表元素作为绘图标题?
- c++ - c++中二维数组的两条对角线之和的绝对差
- python - AttributeError:模块 'torch' 没有 PyTorch 的属性 'rfft'
- typescript - Array.fill() 然后更改二维数组中的值会为 JS 中的列提供相同的输出
- cmd - 是否有 CMD 命令将文件移动到下一个更高的文件夹级别?
- android - 有没有办法从原生安卓应用创建 Facebook 事件?