Forum Moderators: open

Message Too Old, No Replies

Centering image in table

trouble centering an image in a table

         

Str8TalkingBob

6:15 pm on Jan 2, 2010 (gmt 0)

10+ Year Member



Hi all i'm having a problem with a table i've created with 3 images in. I am trying to get the 1st image aligning left, the 2nd centered and the third to the right. It's ok apart from the centered image is aligning to the left for some reason. The code i'm using for the table is:


<table border="0" width="100%" cellpadding="0">
<tr>
<td width="33.3%" valign="top">
<img class="logo" src="image/logo.png"; align="left"; width="287"; height="145">
</td>
<td width="33.3%" valign="top">
<img class="logo2" src="image/logo.png"; align="center"; width="287"; height="145">
</td>
<td width="33.3%" valign="top">
<img class="logo3" src="image/logo.png"; align="right"; width="287"; height="145">
</td>
</tr>
</table>

And the corresponding CSS in my linked CSS file is:


img.logo {border:1px solid green; float: left;}
img.logo2 {border:1px solid green; position:center;}
img.logo3 {border:1px solid green; position:absolute-right;}

I've tried removing the class from the image so it relates to nothing in the css file but it still aligns to the left.

Does anyone have any idea what is going on? :)

dreamcatcher

7:06 pm on Jan 2, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi Str8TalkingBob, a warm welcome to WebmasterWorld. :)

All of the semi colons in your image tags are invalid and are possibly causing unexpected results. Some of the tags are also deprecated now. Try this:


<table border="0" width="100%" cellpadding="0">
<tr>
<td style="width:33%;vertical-align:top;text-align:left">
<img src="image/logo.png" width="287" height="145">
</td>
<td style="width:33%;vertical-align:top;text-align:center">
<img src="image/logo.png" width="287" height="145">
</td>
<td style="width:33%;vertical-align:top;text-align:right">
<img class="logo3" src="image/logo.png" width="287" height="145">
</td>
</tr>
</table>

dc

Str8TalkingBob

7:20 pm on Jan 2, 2010 (gmt 0)

10+ Year Member



Thankyou so much, that solved the problem straight away. I'm just getting back into coding after a very very long break so i'm a little rusty and things have changed quite a lot.

dreamcatcher

9:14 am on Jan 3, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Understandable. Things are changing all the time and there is lots to learn.

Good luck.

dc