472,805 Members | 1,556 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,805 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 4745
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,...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: lllomh | last post by:
How does React native implement an English player?
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

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.