我正在嘗試創建一個網站,其中背景是視頻。我一直在尋找關於如何重新創建Spotify's主頁背景的日子,但似乎無法使其工作。調整爲始終適合瀏覽器的背景視頻
我的問題是,我可以使用瀏覽器或寬度來調整高度,但不能同時使用兩者。與Spotify網站上的視頻不同,它不能隨時擴展以適應瀏覽器。我嘗試了很多東西,其中大部分我都記不起來了。我不介意使用JQuery來實現這種效果。
我當前的代碼是:
<!DOCTYPE html>
<html>
<head>
<title>VideoBG</title>
<style type="text/css">
#videohome {
position:absolute;
height: 100%;
width: 100%;
top:0;
left:0;
right:0;
bottom:0;
}
</style>
</head>
<body>
<video id="videohome" preload="auto" autoplay="true" loop="loop" muted="" volume="0">
<source src="./homepage.mp4" type="video/mp4" />
</video>
</body>
</html>
看看jQuery的BigVideo.js插件:http://dfcb.github.io/BigVideo.js/ – reinder
我在Spotify的主頁上看不到任何視頻,只有某種視差滾動。 – LeBen
@LeBen:只有當您第一次訪問他們的網站時纔會發生這種情況。他指的是這個特定的頁面:https://www.spotify.com/en/video-splash – reinder