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

How to set background transparency in css

coldplay.xixi
coldplay.xixiOriginal
2021-03-15 17:57:318694browse

How to set background transparency in css: First create a new file and write the corresponding style in the div; then add an opacity style to the div. The transparency effect is achieved and the background image of the parent div can be projected.

How to set background transparency in css

The operating environment of this tutorial: windows7 system, css3 version, DELL G3 computer.

How to set a transparent background in css:

1. Write some test code first. Testing HTML is very simple, just two divs, one nested inside the other. , the code is shown in the figure.

How to set background transparency in css

2. Then write the corresponding styles for the two divs, as shown in the picture, which are some relatively basic css codes. In order to display the transparency effect, we set the style to p1 In the div, a background image is added.

How to set background transparency in css

#3. First, take a look at the page that has not yet added a transparent effect.

How to set background transparency in css

4. To add a transparent effect, we can add an opacity style to the div. This is the CSS2 approach. The code is as shown in the figure. A style rule .opacity is added and in Add this style name

How to set background transparency in css

to the p2 div. 5. Take a look at the page with the transparent effect set.

The transparency effect is achieved, and the background image of the parent div can be projected. But there is a flaw, that is, the text on the div becomes blurred because there is also a transparency effect.

How to set background transparency in css

Related learning recommendations: css tutorial

The above is the detailed content of How to set background transparency in css. 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