在其他地方进行过研究,找不到在Bootstrap div / header部分中水平居中视频的解决方案,同时保持视频与顶部垂直对齐 . Div / Headers 部分为100%宽度,在某些视口断点处具有两个固定高度 .
我试过删除/重命名 <header>
标签,以防Bootstrap的样式干扰 . 尝试了 <center>
标记,将视频标记指定为 display:inline
以及许多其他尝试 .
此示例中的视频以某些断点为中心,但在其他方面是左对齐的 . 我希望它在所有视口宽度中居中,并且顶部对齐 .
非常感谢!
HTML:
<header>
<video loop muted autoplay poster="images/3671960.jpg" class="fullscreen-video">
<source src="video/3671960.mp4" type="video/mp4">
</video>
<div class="header-content">
<div class="header-content-inner">
<h1>A bunch of header text.</h1>
</div>
</div>
<div class="launcher">
<div class="launcher-inner">
<a href="#what-i-do" class="btn btn-primary btn-outline-inverse page-scroll text-capitalize">Button text</a>
</div>
</div>
CSS:
header {
position: relative;
text-align: center;
top: 0;
left: 0;
width:100%;
height: 475px;
color: #fff;
overflow: hidden;
margin: 0 auto;
}
header .fullscreen-video {
position: absolute;
top: 0;
left: 0;
min-width:100%;
min-height:100%;
z-index: -100;
}
@media (min-width: 768px) {
header {
height: 665px;
}
}
1 回答
HTML
CSS
Demo Link : https://jsfiddle.net/hellosrini/vwc5hek0/