Home > Web Front-end > JS Tutorial > body text

Method to make png images and png background transparent (supports multiple browsers)_javascript skills

WBOY
Release: 2016-05-16 18:46:57
Original
1488 people have browsed it

Although there are JS programs that allow IE6 to support PNG transparent backgrounds, they are not very convenient. It is better to use CSS. What is used is: IE5.5’s AlphaImageLoader filter.
1.png with transparent background
Solution:

Copy code The code is as follows:

#div1 {
height: 600px;
width: 260px;
padding: 20px;
background-repeat: repeat;
}
html> body #div1 {
background-repeat: repeat;background-image: url(bj1.png);
}
* #div1 {filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod =scale, src="bj1.png")
}

Additional: wildcard character (*) recognized only by IE to define filters in IE browser
Firefox, Opera Browsers that fully support PNG transparent images also support sub-selectors (>)
Syntax:
filter: progid:DXImageTransform.Microsoft.AlphaImageLoader (enabled=bEnabled, sizingMethod=sSize, src=sURL)
Attributes:
enabled: optional. Boolean. Sets or retrieves whether the filter is active. true | false
   true : Default value. Filter activated.
false: Filter is disabled.
sizingMethod : Optional. String. Sets or retrieves how the image of the filtered object is displayed within the boundaries of the object container. crop : Crops the image to fit the object dimensions.
Image: Default value. Increase or decrease the object's size bounds to fit the dimensions of the picture.
Scale: Scale the image to fit within the object’s size boundaries.
src: required. String. Specify the background image using an absolute or relative url address. If this parameter is omitted, the filter will have no effect.
2.png images are transparent
If you directly insert png images into the web page and want to make them transparent, just add the following js code. All directly inserted png images in the entire page can be made transparent. :
Copy code The code is as follows:


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