Home > Web Front-end > HTML Tutorial > How to set video to opaque background in HTML

How to set video to opaque background in HTML

coldplay.xixi
Release: 2023-01-03 09:24:09
Original
4348 people have browsed it

HTML method to set video to opaque background: use loop, autoplay method, directly insert relevant code [].

How to set video to opaque background in HTML

The operating environment of this tutorial: windows7 system, html5 version, DELL G3 computer. This method is suitable for all brands of computers.

How to set video to opaque background in HTML:

Insert the following code first:

<video src="../video/2b.mp4" loop="loop" autoplay="autoplay"></video>
Copy after login
  • loop means loop play

  • autoplay means automatic play

css modified as follows:

<style>
body{
    margin:0;//body外边距设为0;
}
video{
    position: fixed;//视频定位方式设为固定
    right: 0;
    bottom: 0;//视频位置
    min-width: 100%;
    min-height: 100%; //不会因视频尺寸造成页面需要滚动
    width: auto;
    height: auto; //尺寸保持原视频大小
    z-index: -100; //z轴定位,小于0即可
    -webkit-filter: grayscale(20%);//添加灰度蒙版,如果设定为100%则视频显示为黑白
}
</style>
Copy after login

Related learning recommendations: html tutorial

The above is the detailed content of How to set video to opaque background in HTML. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template