📜 ⬆️ ⬇️

Background .png and IE 6 - enforcing the world.

The following bug of the “popular” browser is known - pictures in the .png format, containing sections with alpha transparency are displayed incorrectly. Namely - the area of ​​these sites is filled with gray color (thanks to dreamhelg for a concise description of the essence of what is happening in this case).

Today in his RSS feed I found a link to another article on the confrontation .png and IE. Probably, he took it, as the greater half of those who surprised the headline was higher - with prejudice (they say, again, twenty-five). Nevertheless, it turned out a lot of interesting things. For example, now background .png perfectly obey the background-position and background-repeat properties.

Immediately send all curious to the page with examples and explanations. Everything is implemented using JavaScript, which creates and assigns the necessary element of the page <DD_belatedPNG: rect /> (that is, our .png is “reborn” in VML).

To work you need:

  1. download and connect to a JavaScript HTML document (on the page with examples there are two links - to regular and compressed files);
  2. inside the HTML document, run the function ( DD_belatedPNG.fix () ), which needs, as a parameter, to pass the element selector, on which we perform the manipulation rite .

For example:

  <! - [if IE 6]>
 <script type = "text / javascript" src = "DD_belatedPNG.js"> </ script>
 <script type = "text / javascript">
     DD_belatedPNG.fix ('. Png_bg, .other_class');  // example of connecting classes
 </ script>
 <! [endif] -> 

What is special?


Disadvantages:


In general, the script is quite raw. The first test was released just three days ago. Therefore, additional bugs may appear and the work of the script can be more resource-intensive than we would like. Nevertheless, I think that the thing made by Drew Diller ( Drew Diller , that is the name of the script's author) will be interesting to many, that's why I wrote this brief note.
')
UPD . A third version of the script has been released in which some flaws have been fixed. Including single-pixel indents to the left and above, the appearance of undesirable borders, scrolls, and also the ability to transfer functions to several selectors separated by commas (see the example code above).

Source: https://habr.com/ru/post/46597/


All Articles