How to set transparency for html images

藏色散人
Release: 2021-06-03 10:09:02
Original
3283 people have browsed it

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

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>
Copy after login

needs to be written beforehand and represented by class methods.

<body >
<div class="bodystyle"></div>
</body>
Copy after login

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

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

opacity: 1;
Copy after login

.

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!

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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!