Forum Moderators: not2easy

Message Too Old, No Replies

Centering an image in a header

         

Mr Bo Jangles

1:27 pm on Mar 17, 2004 (gmt 0)

10+ Year Member



Hi all,
I have a CSS sheet with this Div:
#img {
margin:0;
padding:0;
border:0.1px solid #f5f5f5;
background: #f5f5f5 url(../img/pgbg.gif) repeat-x;
}

And in my HTML I use this Div to construct a header: <div id="img">
<img src="img/head_girl.jpg" height="74" alt="">
</div>

This places the jpg image on the left hand side(and a background color, via the CSS), but now a client wants a banner positioned in the middle.
Because of the large number of pages, I don't want to change the HTML, but just change the CSS above to cause the image to centre - what is the best way to achieve that please.

Cheers,

pageoneresults

1:36 pm on Mar 17, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



text-align:center;

Add the above to your CSS for that #img and you should be good to go.

Mr Bo Jangles

1:43 pm on Mar 17, 2004 (gmt 0)

10+ Year Member



Oh, OK, so even though it's not text that'll still work?
Great, many thanks PageOne.

Cheers,

pageoneresults

1:46 pm on Mar 17, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Basically that is the replacement for
align="center"
. You can change it to
right
or
left
depending on your needs. There are other ways to align things using margins but in this case I believe the above is your best option.

Mr Bo Jangles

1:51 pm on Mar 17, 2004 (gmt 0)

10+ Year Member



and what's more it works!

thanks again

Hagstrom

2:14 pm on Mar 17, 2004 (gmt 0)

10+ Year Member



text-align:center;

That's not the right way. Try this thread: [webmasterworld.com...]