我在我的网站上使用YouTube视频背景,似乎花费的时间超过了我想加载的时间。为了绕过这个,我想添加一个背景图像,以显示在视频背后,直到它加载。
有一种简单的方法吗?
由于
HTML:
<section class="small-background-section">
<a id="bgndVideo" class="player" data-property="{videoURL:'https://www.youtube.com/watch?v=iNJdPyoqt8U',containment:'body',autoPlay:true, mute:true, startAt:0, opacity:1}"></a>
<div class="pattern"></div>
<div class="small-background-container">
<center>
<img src="images/NewLogo.png" style='width:50%;max-width: 300px;padding:0px;'>
</center>
</div>
</section>
CSS:
/*
Tutorial Name: Modernize Your Site: Building a YouTube Video Background
Author: Samuel Dalusung
*/
/* GENERAL STYLES
================================================== */
html {
height:100%
}
body {
font:15px/23px 'Raleway',sans-serif;
margin:0;
padding:0;
height:100%;
width:100%;
-webkit-font-smoothing:antialiased;
-webkit-text-size-adjust:100%
}
p {
font-size:20px;
line-height:140%;
text-align:center
}
ul li {
display:inline-block;
list-style:none;
padding-right: 10px;
}
.wrapper {
z-index:600;
position:relative
}
.pattern {
background-image:url(../images/pattern.png);
background-repeat: repeat;
background-attachment:scroll;
width:100%;
height:100%;
position:absolute;
top:0;
left:0
}
.divider {
background-image:url(../images/divider.png);
display:block;
width:300px;
height:35px;
margin:10px auto
}
#colorize {
color:#f1c40f;
font-family:'Lato',sans-serif;
font-size:40px
}
/* BIG VIDEO BACKGROUND
================================================== */
.big-background {
z-index:550;
text-align:center;
height:100%;
min-height:100%;
position:relative;
overflow:hidden
}
.big-background .big-background-container {
width:830px;
max-width:100%;
display:inline-block;
position:absolute;
top:50%;
left:50%;
-webkit-transform:translate(-50%,-50%);
-moz-transform:translate(-50%,-50%);
-ms-transform:translate(-50%,-50%);
-o-transform:translate(-50%,-50%);
transform:translate(-50%,-50%)
}
.big-background-title {
font-family:'Raleway',sans-serif;
font-size:78px;
color:#fff;
font-weight:300;
text-transform:uppercase;
text-align:center;
margin-bottom:22px;
padding-top:20px;
display:inline-block;
background-attachment:scroll;
background-repeat:repeat-x;
background-position:top center
}
a.big-background-btn {
font-family:'Lato',sans-serif;
font-size:13px;
text-transform:uppercase;
text-decoration:none;
color:#fff;
background:transparent;
border:2px solid #fff;
padding:10px 14px;
cursor:pointer;
letter-spacing:2px;
text-align:center;
display:inline-block;
-webkit-transition:.4s background ease;
-moz-transition:.4s background ease;
-o-transition:.4s background ease;
transition:.4s background ease;
}
.big-background-btn:hover {
color:#fff;
background:rgba(255,255,255,0.20)
}
.big-background-default-image {
background:url(../images/sunset.jpg);
background-repeat:no-repeat;
background-position:center center;
background-size:cover;
width:100%;
height:25%;
z-index:0;
backface-visibility:hidden
}
/* ABOUT SECTION
================================================== */
.about-section {
font-family:'Lato',sans-serif;
color:#7f8c8d;
background:#fff;
padding:60px 20px
}
.about-section-container {
text-align:center;
padding-bottom:50px
}
.about-section-title {
font-family:'Raleway',sans-serif;
font-size:40px;
background:#fff;
color:#3d566e;
padding:0 35px;
margin-bottom:22px;
background-attachment:scroll;
background-repeat:repeat-x;
background-position:center center;
text-transform:uppercase
}
a.about-section-btn {
font-family:'Lato',sans-serif;
font-size:13px;
text-transform:uppercase;
text-decoration:none;
color:#34495e;
background:transparent;
border:2px solid #34495e;
padding:10px 14px;
cursor:pointer;
letter-spacing:2px;
text-align:center;
display:inline-block;
-webkit-transition:.4s background ease;
-moz-transition:.4s background ease;
-o-transition:.4s background ease;
transition:.4s background ease;
}
.about-section-btn:hover {
color:#fff;
background: #34495e;
}
/* SMALL VIDEO BACKGROUND
================================================== */
.small-background-section {
font-family:'Raleway',sans-serif;
padding:100px 0;
position:relative;
width:100%;
overflow:hidden
}
.small-background-container {
position:relative;
text-align:center
}
.small-background-title {
font-size:40px;
color:#f1c40f;
font-weight:300;
z-index:10;
display:inline-block;
text-transform:uppercase;
margin-bottom:20px;
margin-top: 20px;
position:relative;
background-attachment:scroll;
background-repeat:repeat-x;
background-position:top center
}
/* SOCIALS
================================================== */
.socials a {
color:#fff
}
.socials a:hover {
color:#bdc3c7
}
nav.demo-nav {
width:350px;
margin:0 auto;
display:block
}
/* NAVIGATION BAR
================================================== */
navi.main-nav {
background:#fff;
height:60px;
z-index:170;
margin:0 auto;
border-bottom:1px solid #dadada;
width:100%;
position:fixed;
top:0;
left:0;
right:0;
text-align: center;
}
/* MEDIA QUERIES
================================================== */
@media screen and (max-width: 768px) {
.about-section-title {
line-height:1
}
}
@media screen and (max-width: 480px) {
.big-background-title {
font-size:58px
}
.small-background-title {
line-height:1
}
/*.player{ display: none;} -> If you want to remove the video bg on a specific viewport w/o plugin*/
}
@media screen and (max-width: 360px) {
.big-background-title,#colorize {
line-height:1
}
}
@media screen and (max-width: 320px) {
.small-background-title {
font-size:30px
}
}
提前非常感谢!