开发者

Ways to set up a video as a background 'image'

开发者 https://www.devze.com 2023-02-09 14:09 出处:网络
I need to set up a website with a video as the background. Will I be able to use z-开发者_JAVA技巧index to position other elements on top of the video?Is there a better alternative?I have not tested

I need to set up a website with a video as the background.

Will I be able to use z-开发者_JAVA技巧index to position other elements on top of the video? Is there a better alternative?


I have not tested it, but you could try to set width/height of <video> to 100% then using z-index let all the others element stay on top of it...

Edit: for example to set video as background entire page

<body style="height: 100%;width: 100%">
<div style="position: fixed; top: 0; width: 100%; height: 100%; z-index: -1;">
 <video src="" width="100%" height="100%" autoplay>
 Your browser does not support the video tag.
 </video>
</div>
... rest of your site


You can not apply it as a CSS background (background property). You can give the effect though using layers which is controlled via the z-index property.


If you are using flash as your video playing method no - flash is ALWAYS on top of anything regardless of z-index, But I imagine this could be done by using the new HTML5 <video> tag.

Failing that convert to a high-frame rate animated image and set as BG...

0

精彩评论

暂无评论...
验证码 换一张
取 消