在 Bootstrap 中水平居中视频
Horizontally center video in Bootstrap
在其他地方进行了研究,找不到在 Bootstrap div / header 部分中将视频水平居中同时保持视频与顶部垂直对齐的解决方案。 Div / header 部分宽度为 100%,在某些视口断点处有两个固定高度。
我已经尝试 removing/renaming <header>
标签以防 Bootstrap 的样式干扰。尝试了 <center>
个标签,将视频标签指定为 display:inline
以及许多其他尝试。
此示例中的视频以某些断点为中心,否则为 left-aligned。我希望它在所有视口宽度中居中,并顶部对齐。
非常感谢!
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;
}
}
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>
</header>
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;
left: 50%;
top: 0;
-ms-transform: translateX(-50%);
-webkit-transform: translateX(-50%);
transform: translateX(-50%);
min-width:100%;
min-height:100%;
z-index: -100;
}
@media (min-width: 768px) {
header {
height: 665px;
}
}
在其他地方进行了研究,找不到在 Bootstrap div / header 部分中将视频水平居中同时保持视频与顶部垂直对齐的解决方案。 Div / header 部分宽度为 100%,在某些视口断点处有两个固定高度。
我已经尝试 removing/renaming <header>
标签以防 Bootstrap 的样式干扰。尝试了 <center>
个标签,将视频标签指定为 display:inline
以及许多其他尝试。
此示例中的视频以某些断点为中心,否则为 left-aligned。我希望它在所有视口宽度中居中,并顶部对齐。
非常感谢!
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;
}
}
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>
</header>
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;
left: 50%;
top: 0;
-ms-transform: translateX(-50%);
-webkit-transform: translateX(-50%);
transform: translateX(-50%);
min-width:100%;
min-height:100%;
z-index: -100;
}
@media (min-width: 768px) {
header {
height: 665px;
}
}