Forum Moderators: not2easy

Message Too Old, No Replies

Unable to center some IMG in the header :(

centering CSS, align, alignment, CSS DIV

         

fmartin

2:55 am on Jan 22, 2008 (gmt 0)

10+ Year Member



Hello all, i would like to get some help with my forum. I put a header, it appears centered correctly in FireFox, but I haven't been able to achieve the same for IE...

I tested all kind of combinations with CSS margins, text-align, div alignments, nested divs...

I know I'm using the deprecated tag align=center for the TD cell, but it just work in FireFox, however IE it's ignoring that... and the CSS?

The current block of code is:

<td style="" align="center" width="1" height="120">
<div id="propio" style=" text-align: center;">
<div id="propio2" style=" margin: 1em auto auto auto; width: 950px;">
<a href="http://www.example.com/index.php"><img src="http://www.example.com/Themes/dilbermc/images/lightred/logo.jpg" style="" usemap="#Map" /></a>
<map name="Map" id="Map">
<area shape="rect" coords="0,0,800,170" href="http://www.example.com" />

<area shape="rect" coords="226,168,396,193" href="javascript:window.external.AddFavorite('http://www.example.com','ForoFeminista T&iacute;as Buenas');" >
<area shape="rect" coords="8,165,216,194" href="#" onclick="this.style.behavior='url(#default#homepage)';this.setHomePage('http://www.forofeminista.com');" >example
</map>
</div>
</div>
</td>

The DOCTYPE is:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

fmartin

3:09 am on Jan 22, 2008 (gmt 0)

10+ Year Member



Finally I got a solution, at least it works in IE now.. the width for the Cell was set to much less than the image width.

eelixduppy

3:10 am on Jan 22, 2008 (gmt 0)



Glad you found your solution. Welcome to WebmasterWorld, btw :)

swa66

12:23 am on Jan 23, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Personally I find mixing the abused table layout with CSS very difficult to get right. Basically IE's idea seems to be you can't really control what tables do in CSS (while the standard specifies it all).

You have 3 ways of centering wrapped around each other, perhaps that's just overkill.

The standard way is to use left and right margins of "auto".
IE often prefers a parent element that centers the text.
And you have a td that's centered as well.

While to humans it might be clear that you want it centered, some of those less than perfect parsers might have more trouble grasping what you want to achieve.

Since you said it's part of a forum, I'll presume it's going to be very hard to remove the td, so I'd just kick out the divs and style the td the old fashioned way, or with css if it brings you extra control.
Mixing both just isn't something that works all that great in my experience.

fmartin

2:14 am on Jan 23, 2008 (gmt 0)

10+ Year Member



Thanks for the information, very useful