In the process of creating a website for customers, one of the most difficult problems is to process the background transparency problem of PNG images, because it is troublesome to be compatible with different browsers.
After a long time, I finally found a solution.Iepngfix. HTC.
Iepngfix. How to Use HTC:
- Download the script and decompress iepngfix.htcand blank.gif to the appropriate directory ,. HTC stands for HTML components. The file is a 1x1 pixel transparent GIF image in CSS. If this file is missing, the PNG Image inserted by the label is displayed as a Red Cross-stick.
- In iepngfix.htc, modify the path of blank.gif. var blankimg uses the correct path of 'blank.gif ', which is the only configuration to be modified.
- In CSS, You need to associate the transparent PNG element with the. HTC file. Example: * {behavior: URL (iepngfix. HTC )}
In the preceding three steps, IE6 supports transparent PNG images.
I thought it would be a good thing, and later I found that not only that is the case!
During our testing process, the local environment is ready for handling; it can be tested on the testing machine.
However, when it finally arrived at the production machine, it suddenly found that it could not work! In IE6, the blue background is displayed.
I found the cause for half a day. After comparative analysis, I found thatCodeIt is the same as that on the test machine, but the problem still exists. What should I do?
Later, I directly searched for the iepngfix. HTC website and found that I did not provide any specific server environment requirements. The problem cannot be solved !!!
In addition, the demo file is uploaded to the testing machine and production machine, and the original problem is found on the production machine. No problem is displayed on the test machine, and the production machine does not work.
This eliminatesProgramProblems.
Later, I finally found another solution, that is, to replace the previous PNG image format, the previous one is png24, and now all are replaced with png8, in this way, IE6 can be identified and the background is transparent!
Therefore, the summary is:
To make the PNG Image background transparent:
The safest way is to convert the format to png8;
If iepngfix. HTC is okay on the server, iepngfix. HTC is also a good choice!
In addition, to convert png24 to png8, the method is also very simple. You can use Photoshop to convert it.
The specific method for converting png24 to png8 is:File-storage for Web and device formats-In presets, select PNG-8 and transparency and save.