Home >Web Front-end >Front-end Q&A >How to set transparency for html images

How to set transparency for html images

藏色散人
藏色散人Original
2021-06-03 10:09:023404browse

htmlHow to set the transparency of the image: first create a div; then set a class name; finally set the transparency of the image through attributes such as "filter:alpha(opacity=50);opacity:0.5;".

How to set transparency for html images

The operating environment of this article: Windows7 system, HTML5&&CSS3 version, Dell G3 computer.

About setting the transparency of the background image (html css)

Set the transparency of the background image, not the color, it is the image display

This Just like some blogs can change the background image as the theme, after reading it for a long time, I finally figured out that

6c04bd5ca3fcae76e30b72ad730ca86d cannot directly set the transparency of the image

You need to use< ;div>

<style type="text/css">
.bodystyle{
filter:alpha(opacity=50);  
-moz-opacity:0.5;  
-khtml-opacity: 0.5;  
opacity: 0.5;
width:100%;
position:absolute;
background:url(图像/8.JPG) ; 
background-attachment:fixed;
}
</style>

needs to be written beforehand and represented by class methods.

<body >
<div class="bodystyle"></div>
</body>

Then reference this class in the div, you can set the image transparency

But there are also problems with this. If there is text in the middle, it will also become a transparent font, and it must be used as the background For pictures, you need to put the text in the middle of two dc6dce4a544fdca2df29d5ac0ea9906b

, so you need to set the font transparency of the text in css

opacity: 1;

.

Recommended learning: html video tutorial

The above is the detailed content of How to set transparency for html images. 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