PDA

View Full Version : background image in table <td> different in IE and Firefox



belper
15 Nov 2009, 06:27 PM
Hello,

I have this php code :



//echo $i."<br>end-".$end."-start-".$start;
echo "<table bgcolor=#666666 bordercolor=#C0C0C0 border=0 width=700 cellspacing=0 cellpadding=10><tr><td background=\"images/topbar.gif\" height=\"45\"></td></tr><tr><td>";
echo "<b>$listDatetxt: </b>";
$lines[$i]->showDate();
echo "<br><b>$listnametxt: </b>";
$lines[$i]->showFrom();
echo "</a><br><br><b>$listMessagetxt: </b>";
$lines[$i]->showMessage();
echo "</td></tr>
<tr><td background=\"images/footbar.gif\" height=\"30\"></td></tr></table><br>";
}

echo "<center>";


This is the problem :

In Firefox the table is shown correctly, except that text is not centered
In IE text is centered but the background images (topbar and footbar) seam to be ‘repeated’ in the in the imagebar.
Sizes of my images :
topbar.gif 700x45
footbar.gif 700x30
So obviously I am doing something wrong (newbee !)
Someone can help me ?

Thanks

usedearplugs
15 Nov 2009, 11:38 PM
My guess as to the cause is the cellpadding being 10... but as to the solution...

I would use (and I write this in plain html rather than php)

<td height="45" style="background-image: url('images/topbar.gif'); background-repeat:none;">

Then you may also need to assign the position of the background with styles also, depending on what those images are being used for... for instance, if the top one needs to connect to the body of your table then you might need to position it to the bottom of the cell... but at the same time, having it in tables at all will probably present problems if that's what you're trying to do.