css 具有移动后备图像的视频标头

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了css 具有移动后备图像的视频标头相关的知识,希望对你有一定的参考价值。

<div id="video-header">
  <div class="video-color-overlay full-height" style="opacity: 0.7;"></div>
  <div class="mobile-video-image hidden-md visible-sm visible-xs full-height" style="background-image: url(./theme/assets/videos/home-preview.png); position:absolute;width:100%;"></div>
  <div class="video-wrap full-height">
    <video class="video-bg full-height hidden-sm hidden-xs" width="100%" height="100%" preload="auto" loop="" autoplay="" muted="">
      <source src="<?php echo $siteurl;?>theme/assets/videos/home-video.webm" type="video/webm">
      <source src="<?php echo $siteurl;?>theme/assets/videos/home-video.mp4" type="video/mp4">
    </video>
  </div>
  <div class="video-comment container full-height">
    <div class="vertical-center animate" data-animation="fadeIn">
      <?php include('./theme/html/homepage-banner-text.html');?>
    </div> 
  </div>
</div>
/* ============================================= */

/* Template - Video Banner
  ============================================== */
  #video-header{
    max-height: 950px;
  }
  #video-header + .purple-background {
    margin:0;
    padding:20px 0;
  }
  #video-header video{
    object-fit: cover;
  }
  .video-color-overlay{
    background-color: #777;
    opacity: 0.7;
    position: absolute;
    width: 100%;
    z-index: 1;
  }
  .video-wrap{
    position: absolute;
    width: 100%;
  }
  .video-wrap::before{
    background: rgba(255,255,255,0.5);
    bottom: 89px;
    content: '';
    height: 6px;
    left: 50%;
    margin-left: -1px;
    opacity: 1;
    position: absolute;
    width: 2px;
    z-index: 100;
    animation: scrollDownHero 2s linear infinite;
  }
  .video-wrap::after {
    background: rgba(255,255,255,0.3);
    bottom: 55px;
    content: '';
    height: 40px;
    left: 50%;
    margin-left: -1px;
    position: absolute;
    width: 2px;
    z-index: 2;
  }
  .video-comment {
    height: 100%;
    z-index: 3;
  }
  .video-comment .vertical-center{
   width: 100%;
   height: 35%;
   position: absolute;
   top: 40%;
   left: 0%;
   text-align: center;
  }
  .video-comment h1, .video-comment h2,  .video-comment h3, .video-comment h4{
    text-align: center;
    color: #fff;
  }
  .video-comment h1{
    font-size: 42px;
    font-family: 'EB Garamond', sans-serif;
    font-weight: 200;
    text-transform: uppercase;
    letter-spacing: 1px;
    line-height: 52px;
  }
  .video-comment h2{
    font-size: 26px;
    font-family: 'EB Garamond', sans-serif;
    font-weight: 200;
    text-transform: uppercase;
    letter-spacing: 1px;
    line-height: 52px;
  }
  .video-comment h3{
    font-size: 26px;
    font-family: 'EB Garamond', sans-serif;
    font-weight: 200;
    text-transform: uppercase;
    letter-spacing: 1px;
    line-height: 52px;
  }
  .video-comment h4{
    font-size: 16px;
    line-height: 28px;
    font-family: 'Open Sans', sans-serif;
    text-transform: uppercase;
    letter-spacing: 1px;
  }
  .video-comment a.btn{
    background: transparent;
    background-image: none;
    border: 2px solid #fff;
    font-size: 14px;
    letter-spacing: 1px;
    text-transform: uppercase;
    margin: 12px 0;
    padding: 12px 20px; 
    border-radius: 0;
    text-shadow: none;
    color:#fff;
    font-family: 'Open Sans', sans-serif;
    transition: all 0.4s linear;
  }
  .video-comment a.btn:hover{
    background: #fff;
    color:#333;
  }


  /* Large devices (desktops, 992px and up) */
  @media (max-width: 1200px) {}

  /* Medium devices (desktops, 1024px and up) */
  @media (max-width: 1025px) {}

  /* Small devices (tablets, 768px and up) */
  @media (max-width: 769px) {}

  /* Xtra Small Devices (phone, 768px and below) */
  @media (max-width: 425px) {
    .video-comment h1{
      font-size: 28px;
      line-height: 36px;
    }
    .video-comment h2{
      font-size: 18px;
      line-height: 28px;
    }
    .video-comment h4{
      font-size: 14px;
      line-height: 18px;
    }
    .video-wrap::before, .video-wrap::after{
      display: none;
    }
    .video-comment .vertical-center{
      top:39%;
    }
  }

以上是关于css 具有移动后备图像的视频标头的主要内容,如果未能解决你的问题,请参考以下文章

即使浏览器支持 html5 视频,也显示后备图像

WebP 后备图像未加载

使用 CSS 的后备图像

HTML5 视频的图像占位符后备

html 具有闪回后备的HTML5视频

html 具有PNG后备的SVG图像