473,378 Members | 1,468 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

PNG background-repeat bug in IE6

XedinUnknown
Hi!

I am new to this forum, but not new to web design and programming. Nevertheless, I have never tried to use PNG so extensively in my pages. here's the problem.

First, I have found that the PNG backgrounds and images had no transparency and grey around them when viewed in IE6, but I solved this bug using this hack. It works great, but then another problem came up: a background image that had the solution applied to was not repeating itself where it should have. IE6 was just ignoring the background repeat. Below is the markup code for which the validator gives 3 insignificant errors:
[HTML]<!DOCTYPE html public "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>

<HEAD>

<TITLE>Пирожки ))</TITLE>
<LINK rel="stylesheet" type="text/css" href="css1.css">

</HEAD>

<BODY id="body">

<TABLE style="margin: 5px;" width="99%" cellpadding="0" cellspacing="0" border="0">
<!-- HEADER STARTS here -->
<TR>
<TD id="header_left" height="187" width="116">&nbsp;</TD>
<TD id="header_middle" height="187" align="center"><IMG src="logo.png" alt="Пироги"></TD>
<TD id="header_right" height="187" width="118">&nbsp;</TD>
</TR>
<!-- HEADER ENDS here -->
<TR>
<TD colspan="3" height="15"></TD><!-- This is the spacing between the header and the body -->
</TR>
<!-- The BODY STARTS here -->
<TR>
<TD colspan="3">
<TABLE cellpadding="0" cellspacing="0" border="0" width="100%">
<TR>
<TD width="206" height="70"><IMG src="center_top_left.png"></TD>
<TD background="center_top_middle.png" align="center" valign="top"><IMG src="slogan.png" alt="Слоган"></TD>
<TD width="224" height="70"><IMG src="center_top_right.png"></TD>
</TR>
</TABLE>
</TD>
</TR>
<TR>
<TD colspan="3">
<TABLE cellpadding="0" cellspacing="0" border="0" width="100%">
<TR>
<TD background="center_middle_left.png" width="11">&nbsp;</TD>
<TD background="center_middle_center.png">
<TABLE cellpadding="0" cellspacing="0" border="0" width="100%">
<TR>
<TD width="163">
<!-- MENU box STARTS here -->
<TABLE cellpadding="0" cellspacing="0" border="0" width="100%">
<TR>
<TD background="mnu_btn.png" width="163" height="34" align="center">Row 1</TD>
</TR>
<TR>
<TD background="mnu_btn.png" width="163" height="34" align="center">Row 2</TD>
</TR>
<TR>
<TD background="mnu_btn.png" width="163" height="34" align="center">Row 3</TD>
</TR>
</TABLE>
<!-- CONTENT box ENDS here -->
</TD>
<TD style="padding: 25px">
<!-- CONTENT box STARTS here -->
<TABLE cellpadding="0" cellspacing="0" border="1">
<TR>
<TD></TD>
</TR>
</TABLE>
<!-- CONTENT box ENDS here -->
</TD>
</TR>
</TABLE>
</TD>
<TD background="center_middle_right.png" width="12">&nbsp;</TD>
</TR>
<TR>
<TD background="center_bottom_left.png" height="12"></TD>
<TD background="center_bottom_middle.png" height="12"></TD>
<TD background="center_bottom_right.png" height="12"></TD>
</TR>
</TABLE>
</TD>
</TR>
<!-- The BODY ENDS here -->
</TABLE>

</BODY>

</HTML>[/HTML]

I really needed the image to repeat. And I was almost out of hope when posting here, but my pride has saved me: I decided to read the comments to the above posted solution for the transparency problem. And I found it, though I couldn't find it anywhere else. For those, who don't feel like looking for it in the comments, here's the citation:

As mentioned earlier, repeating in any fashion is impossible. However, it is possible to ‘stretch’ the background over the whole area.

If you’re using a solid translucent color png background, you can stretch it across the whole area.

To do so, first do the standard css: .trans_white { background-image: url(trans_white.png); background-repeat: repeat; behavior: url(iepngfix.htc); }

Notice I added in the background-repeat. This is the variable that will indicate to the script to stretch it.

Now, we modify the script (iepngfix.htc) to look at the repeat: Find this: style.backgroundImage = ‘none’; filt(s, ‘crop’);

Replace it with this: style.backgroundImage = ‘none’; if(currentStyle.backgroundRepeat==”repeat”) filt(s, ‘scale’); else filt(s, ‘crop’);

Now, whenever a background has a background-repeat set to ‘repeat’, it’ll stretch the background image to encompass the whole area.

This can also be done to mimic repeat-x and repeat-y. You just need the div/td/whatever to ONLY encompass the area desired.


I hope this helps whoever has encountered a similar problem. Good luck!
May 21 '08 #1
2 4784
hsriat
1,654 Expert 1GB
I had the same problem, but I never searched for such way outs. I just converted the PNG to GIF and applied it as background-image.

Another thing that may bother you later is gamma channel in the PNGs. IE (even IE7) doesn't support gamma channel which, to a layman, seems like the color is different from what it was actual. So its better to use GIFs, if you can convert one. If you need to know how to convert a PNG into GIF, just download GIMP.

And have a look at this page if you want to know exactly what the problem is.
May 23 '08 #2
poe
32
This "fix" really only works for simple PNG images that will work when stretched. If that's the case, an equivalent GIF would be a better choice for the image anyways. I don't understand what can't be achieved with a GIF?
May 23 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: erik | last post by:
Is it posssible to inherit the previous pages (parent pages) background image? Is there a script out there I could look at? Thanks
12
by: Stanimir Stamenkov | last post by:
Here are two cases regarding inline-level elements' line-height, padding and background, which I doesn't understand: <div style="background: black; color: white; line-height: 1.5">...
25
by: Neal | last post by:
According to the CSS lint at http://htmlhelp.org/tools/csscheck/, "The shorthand background property is more widely supported than background-color." Can anyone point me to, or provide, information...
1
by: CMAR | last post by:
I have a design of a frameless page on my practice website: http://home.ne.rr.com/thespar/designerN.htm The idea is to have a #left navigation bar which is absolutely positioned and which...
27
by: Kevin Yu | last post by:
When I declare on HTML page <LINK href="mycss.css" type="text/css" rel=stylesheet /> .... <BODY class=myclass> in mycss.css BODY { FONT-WEIGHT: bold; FONT-SIZE: 12px; FONT-FAMILY:...
3
by: Peter Williams | last post by:
Hi All, I want to write some javascript for a html page which does the following. Imagine that the page contains a table with 2 columns and 3 rows, e.g.: +---+---+ | A | B | +---+---+
5
by: proximus | last post by:
Hi, I am trying to change the background of table TD's. The problem is that I have no access to the HTML code. SO I am trying to alter this using Javascript/DOM in an external .js file. I...
0
by: Jeb Hunter | last post by:
Well, how can I describe this succinctly? I have a page with DIVs that us background images to produce a border effect. It works perfectly well, but I want to make up (for now) 3 different...
6
by: Rob | last post by:
Hello, I'm sure this has come up before. I have need for a collection of all elements/objects in an HTML document that have any kind of an attribute (HTML or CSS) that is making use of a URL to...
19
by: david.karr | last post by:
If in my CSS I set the "background-color" property on the "body" element, it only covers the background of the elements defined in the body, up to the current width and height of the page. However,...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.