search
HomeWeb Front-endHTML Tutorial烦人的IE7、8,半透明滤镜(filter:alpha)失效、png半透明失效的解决办法_html/css_WEB-ITnose

在项目中的问题,之前用的是用IETest测试IE7,8发现背景透明设置无效,后来找文章解决!看了一些资料,做下总结。

几种IE半透明CSS样式

IE8里可以这样写 -ms-filter:”progid:DXImageTransform.Microsoft.Alpha(opacity=50)”; 

IE7里可以这样写 filter:progid:DXImageTransform.Microsoft.Alpha(opacity=50); 

IE6,IE7,IE8里都可以这样写 filter:alpha(opacity=50)

progid:DXImageTransform.Microsoft这种写法很是难懂,看起来也烦,一般倾向filter:alpha(opacity=50)写法;

看资料说前两种写法,是和MS的ActiveX技术一条路的,第三种看起来没有ActiveX,但本质也还是ActiveX一路的;这个可以在安全选项里面禁掉所有的ActiveX试试,包括这个滤镜在内的所有IE滤镜立刻就无效;

DIV背景透明有两种

一种是DIV本身和内部元素全部透明,另外是DIV透明,子元素不透明

第一种解决方法是用background: rgba(255, 255, 255, 0.82);设置DIV样式,子元素就不会透明了

另外是将DIV外再添加一个父DIV,父DIV设置相对,原DIV设置绝对位置用filter:设置透明;其他子元素放到原DIV同级位置,其他元素也设置position:absolute ,这也是一种解决办法

 

------------------------------

看了作者iefans的半透明失效文章,摘下了

png半透明失效的原因

 

IE7,IE8都是直接支持了png图片的alpha的,这回我的IE8里的png半透明失效的原因不明,怀疑可能跟360Safe的某些动作有关,仅仅只是怀疑而已。

 

很多情况会影响到ie8的png效果,这回运气比较好一点,在网上找到了方法,改了改注册表,就解决了问题。这里我们列举几种可能导致png注册表选项被破坏的情形。

 

1.(原因:.png在浏览器没有扩展值或出错)

开始->运行-regedit,打开注册表,HKEY_LOCAL_MACHINESOFTWAREMicrosoftInternet ExplorerEmbedExtnToClsidMappings看.png存不存在。如果.png不存在,鼠标点它的上一层,也就是EmbedExtnToClsidMappings,然后按鼠标右键新建项,输入.png,然后点.PNG,双击默认值,在数值数据那粘贴“clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B”。

这是我上次成功的方法,这次不行了!

 

2.(原因:.png在系统中的文件损坏)

使用 开始->运行,输入 “regsvr32 c:windowssystem32pngfilt.dll”

如果在注册时出现 “已加载 c:windowssystem32pngfilt.dll,但没有找到DllRegisterSever 输入点。无法注册这个文件”,则表明这个文件可能损坏了,你要去别的机子去Copy一个好的过来覆盖。再进行一次注册。

 

3.(原因:我们伟大的Apple公司的QuickTime程序干扰了注册表)

开始->运行->regedit,启动注册表,找到HKEY_CLASSES_ROOTMIMEDatabaseContent Type

将其中中文名的以及乱码的都删除即可如[视频/mp4]。

 

4.(原因:注册表信息错误!我这次就是这个问题,合并注册表后,下面的信息会自动覆盖掉有问题的信息)

将下面的内容存成.reg文件,然后右键->合并。

 

Windows Registry Editor Version 5.00

 

;PNG file association fix for Windows XP

;Created on May 17, 2007 by Ramesh Srinivasan

 

[HKEY_CLASSES_ROOT.PNG]

“PerceivedType”=”image”

@=”pngfile”

“Content Type”=”image/png”

 

[HKEY_CLASSES_ROOT.PNGPersistentHandler]

@=”{098f2470-bae0-11cd-b579-08002b30bfeb}”

 

[HKEY_CLASSES_ROOTpngfile]

@=”PNG Image”

“EditFlags”=dword:00010000

“FriendlyTypeName”=hex(2):40,00,25,00,53,00,79,00,73,00,74,00,65,00,6d,00,52,

00,6f,00,6f,00,74,00,25,00,5c,00,73,00,79,00,73,00,74,00,65,00,6d,00,33,00,

32,00,5c,00,73,00,68,00,69,00,6d,00,67,00,76,00,77,00,2e,00,64,00,6c,00,6c,

00,2c,00,2d,00,33,00,30,00,35,00,00,00

“ImageOptionFlags”=dword:00000003

 

[HKEY_CLASSES_ROOTpngfileCLSID]

@=”{25336920-03F9-11cf-8FD0-00AA00686F13}”

 

[HKEY_CLASSES_ROOTpngfileDefaultIcon]

@=”shimgvw.dll,2″

 

[HKEY_CLASSES_ROOTpngfileshell]

@=”open”

 

[HKEY_CLASSES_ROOTpngfileshellopen]

“MuiVerb”=”@shimgvw.dll,-550″

 

[HKEY_CLASSES_ROOTpngfileshellopencommand]

@=”rundll32.exe C:\WINDOWS\system32\shimgvw.dll,ImageView_Fullscreen %1″

 

[HKEY_CLASSES_ROOTpngfileshellopenDropTarget]

“Clsid”=”{E84FDA7C-1D6A-45F6-B725-CB260C236066}”

 

[HKEY_CLASSES_ROOTpngfileshellprintto]

 

[HKEY_CLASSES_ROOTpngfileshellprinttocommand]

@=”rundll32.exe C:\WINDOWS\system32\shimgvw.dll,ImageView_PrintTo /pt ”%1” ”%2” ”%3” ”%4”"

 

[HKEY_CLASSES_ROOTSystemFileAssociations.PNG]

“ImageOptionFlags”=dword:00000003

 

[-HKEY_CURRENT_USERSoftwareMicrosoftWindowsCurrentVersionExplorerFileExts.PNG]

 

[-HKEY_CLASSES_ROOTMimeDatabaseContent Typeimage/x-png]

 

[-HKEY_CLASSES_ROOTMimeDatabaseContent Typeimage/png]

 

[HKEY_CLASSES_ROOTMimeDatabaseContent Typeimage/x-png]

“Extension”=”.png”

“Image Filter CLSID”=”{A3CCEDF7-2DE2-11D0-86F4-00A0C913F750}”

 

[HKEY_CLASSES_ROOTMimeDatabaseContent Typeimage/x-pngBits]

“0″=hex:08,00,00,00,ff,ff,ff,ff,ff,ff,ff,ff,89,50,4e,47,0d,0a,1a,0a

 

[HKEY_CLASSES_ROOTMimeDatabaseContent Typeimage/png]

“Extension”=”.png”

“Image Filter CLSID”=”{A3CCEDF7-2DE2-11D0-86F4-00A0C913F750}”

 

[HKEY_CLASSES_ROOTMimeDatabaseContent Typeimage/pngBits]

“0″=hex:08,00,00,00,ff,ff,ff,ff,ff,ff,ff,ff,89,50,4e,47,0d,0a,1a,0a

 

[HKEY_CLASSES_ROOTCLSID{A3CCEDF7-2DE2-11D0-86F4-00A0C913F750}]

@=”CoPNGFilter Class”

 

[HKEY_CLASSES_ROOTCLSID{A3CCEDF7-2DE2-11D0-86F4-00A0C913F750}InProcServer32]

@=”C:\WINDOWS\system32\pngfilt.dll”

“ThreadingModel”=”Both”

 

[HKEY_CLASSES_ROOTCLSID{A3CCEDF7-2DE2-11D0-86F4-00A0C913F750}ProgID]

@=”PNGFilter.CoPNGFilter.1″

 

[HKEY_CLASSES_ROOTPNGFilter.CoPNGFilter]

@=”CoPNGFilter Class”

 

[HKEY_CLASSES_ROOTPNGFilter.CoPNGFilterCLSID]

@=”{A3CCEDF7-2DE2-11D0-86F4-00A0C913F750}”

 

[HKEY_CLASSES_ROOTPNGFilter.CoPNGFilter.1]

@=”CoPNGFilter Class”

 

[HKEY_CLASSES_ROOTPNGFilter.CoPNGFilter.1CLSID]

@=”{A3CCEDF7-2DE2-11D0-86F4-00A0C913F750}”

 

 

当PNG遭遇filter:alpha

 

IE系列的PNG问题是一个广受诟病、由来已久、至今未较好解决的问题,从IE6的不支持到IE7/8的缺陷支持,算是有所进步,但还有很多不健全。比如大家可以试试当PNG遭遇filter:alpha的情况,非常奇怪的现象,PNG在IE7下出现黑色背景。

 

这个在蓝色经典上有朋友说明了该问题,“出现背景变黑应该是给整个窗体设置了透明度导致,那么对于IE7(可能还包括IE8)来说,它虽然提供了对半透明PNG的支持,但这种支持是不健全的。这种不健全的一种表现就是,当你为半透明PNG图片(或使用半透明PNG作为背景的元素)设置透明度时,PNG图片的半透明部分会显示为黑色(但不透明部分的显示是正常的)。

值得一提的是,IE 实现透明度是通过其私有的 CSS 滤镜的方式,而非标准的 CSS3 属性。而且IE透明滤镜本身就是存在 bug 的,当然这里就不多说了”

 

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
From Text to Websites: The Power of HTMLFrom Text to Websites: The Power of HTMLApr 13, 2025 am 12:07 AM

HTML is a language used to build web pages, defining web page structure and content through tags and attributes. 1) HTML organizes document structure through tags, such as,. 2) The browser parses HTML to build the DOM and renders the web page. 3) New features of HTML5, such as, enhance multimedia functions. 4) Common errors include unclosed labels and unquoted attribute values. 5) Optimization suggestions include using semantic tags and reducing file size.

Understanding HTML, CSS, and JavaScript: A Beginner's GuideUnderstanding HTML, CSS, and JavaScript: A Beginner's GuideApr 12, 2025 am 12:02 AM

WebdevelopmentreliesonHTML,CSS,andJavaScript:1)HTMLstructurescontent,2)CSSstylesit,and3)JavaScriptaddsinteractivity,formingthebasisofmodernwebexperiences.

The Role of HTML: Structuring Web ContentThe Role of HTML: Structuring Web ContentApr 11, 2025 am 12:12 AM

The role of HTML is to define the structure and content of a web page through tags and attributes. 1. HTML organizes content through tags such as , making it easy to read and understand. 2. Use semantic tags such as, etc. to enhance accessibility and SEO. 3. Optimizing HTML code can improve web page loading speed and user experience.

HTML and Code: A Closer Look at the TerminologyHTML and Code: A Closer Look at the TerminologyApr 10, 2025 am 09:28 AM

HTMLisaspecifictypeofcodefocusedonstructuringwebcontent,while"code"broadlyincludeslanguageslikeJavaScriptandPythonforfunctionality.1)HTMLdefineswebpagestructureusingtags.2)"Code"encompassesawiderrangeoflanguagesforlogicandinteract

HTML, CSS, and JavaScript: Essential Tools for Web DevelopersHTML, CSS, and JavaScript: Essential Tools for Web DevelopersApr 09, 2025 am 12:12 AM

HTML, CSS and JavaScript are the three pillars of web development. 1. HTML defines the web page structure and uses tags such as, etc. 2. CSS controls the web page style, using selectors and attributes such as color, font-size, etc. 3. JavaScript realizes dynamic effects and interaction, through event monitoring and DOM operations.

The Roles of HTML, CSS, and JavaScript: Core ResponsibilitiesThe Roles of HTML, CSS, and JavaScript: Core ResponsibilitiesApr 08, 2025 pm 07:05 PM

HTML defines the web structure, CSS is responsible for style and layout, and JavaScript gives dynamic interaction. The three perform their duties in web development and jointly build a colorful website.

Is HTML easy to learn for beginners?Is HTML easy to learn for beginners?Apr 07, 2025 am 12:11 AM

HTML is suitable for beginners because it is simple and easy to learn and can quickly see results. 1) The learning curve of HTML is smooth and easy to get started. 2) Just master the basic tags to start creating web pages. 3) High flexibility and can be used in combination with CSS and JavaScript. 4) Rich learning resources and modern tools support the learning process.

What is an example of a starting tag in HTML?What is an example of a starting tag in HTML?Apr 06, 2025 am 12:04 AM

AnexampleofastartingtaginHTMLis,whichbeginsaparagraph.StartingtagsareessentialinHTMLastheyinitiateelements,definetheirtypes,andarecrucialforstructuringwebpagesandconstructingtheDOM.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools