Home  >  Article  >  Web Front-end  >  How to set background transparency in html

How to set background transparency in html

青灯夜游
青灯夜游Original
2021-05-17 16:40:4058211browse

In HTML, if it is a background color, you can use the rgba() function or opacity attribute to set the color transparency; if it is a background image, you can use the opacity attribute and "filter:opacity(%)" style to set it Image transparency.

How to set background transparency in html

The operating environment of this tutorial: Windows 7 system, CSS3&&HTML5 version, Dell G3 computer.

1. Set the transparency of the background color--use the rgba() function or the opacity attribute

Example 1:





RGB 颜色,并使用透明度:

红色

绿色

蓝色

灰色

黄色

樱桃色

Rendering:

How to set background transparency in html

Example 2:




背景色不透明,文字不透明!

背景色透明,文字也透明!

Rendering:

How to set background transparency in html

2. Set the transparency of the background image--use the opacity attribute and "filter:opacity(%)" style

Example 1:



	
		
		
	
	
		

原图:

透明度为50%:

透明度为20%:

How to set background transparency in html

Example 2:



	
		
		
	
	
		

原图:

透透明度为0.5:

透明度为02:

How to set background transparency in html

(Learning video sharing: css video tutorial, "html video tutorial")

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

Statement:
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