適合YouTube影片我想重新創建:DEMO動態延伸使用API
HTML
<header role="banner">
<div id="wrapper-video">
<video poster="" autoplay loop>
<source src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/156843/cut.mp4"
type="video/mp4; codecs=avc1.42E01E,mp4a.40.2">
</video>
</div>
</header>
CSS
section[role="banner"] {
position: relative;
width: 100%;
}
#wrapper-video {
position: fixed;
top: -50%;
left: -50%;
width: 200%;
height: 200%;
z-index: -100;
}
#wrapper-video video {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
margin: auto;
min-width: 50%;
min-height: 50%;
}
...但替換YouTube視頻加載視頻通過YouTube的API將播放器加載到DIV中,如下所示:
<div id="player"></div>
但是,只要我開始更改html,居中關閉,即使我將上述更改爲圖像(作爲概念驗證),居中也會關閉。我在這裏做錯了什麼?
如果我只是將其更改爲#wrapper-video2並重命名它所在的DIV,那麼是否#wrapper-video視頻會做一些意想不到的事情?
這也許是更適合您? https://codepen.io/dudleystorey/pen/PZyMrd – Miro
@Miro:這個工程,但仍然失敗時,屏幕變得超寬或超級瘦。 – Patrick