HighDots Forums  

Image Dentering

Cascading Style Sheets Layout/presentation on the WWW (comp.infosystems.www.authoring.stylesheets)


Discuss Image Dentering in the Cascading Style Sheets forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Ron Barnett
 
Posts: n/a

Default Image Dentering - 01-19-2009 , 06:39 PM






Hello All,

I'm getting stuck on how to get an image to centre inside a DIV.
When a page is displayed in IE,
<div style='text-align:center;'>
<img ... >
</div>
does the job as IE handles the image as if it were text

However in firefox / chrome / safari etc the image sits on the left.
Is there a foolproof centre for the div containing an image?

I have read somewhere about using style='margin:auto;' but that doesn't
seem to work.
Any suggestions welcome.

Cheers

Ron




Reply With Quote
  #2  
Old   
Evertjan.
 
Posts: n/a

Default Re: Image Dentering - 01-19-2009 , 06:54 PM






Ron Barnett wrote on 20 jan 2009 in
comp.infosystems.www.authoring.stylesheets:

Quote:
Hello All,

I'm getting stuck on how to get an image to centre inside a DIV.
When a page is displayed in IE,
div style='text-align:center;'
img ...
/div
does the job as IE handles the image as if it were text

However in firefox / chrome / safari etc the image sits on the left.
Is there a foolproof centre for the div containing an image?

I have read somewhere about using style='margin:auto;' but that
doesn't seem to work.
Any suggestions welcome.
http://www.google.com/search?q=image+center+margin.auto+css

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)


Reply With Quote
  #3  
Old   
Ron Barnett
 
Posts: n/a

Default Re: Image Centering Solved - 01-19-2009 , 07:33 PM



"Evertjan." <exjxw.hannivoort (AT) interxnl (DOT) net> wrote

Quote:
Ron Barnett wrote on 20 jan 2009 in
comp.infosystems.www.authoring.stylesheets:

Hello All,

I'm getting stuck on how to get an image to centre inside a DIV.
When a page is displayed in IE,
div style='text-align:center;'
img ...
/div
does the job as IE handles the image as if it were text

However in firefox / chrome / safari etc the image sits on the left.
Is there a foolproof centre for the div containing an image?

I have read somewhere about using style='margin:auto;' but that
doesn't seem to work.
Any suggestions welcome.

http://www.google.com/search?q=image+center+margin.auto+css

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Thanks,

I discovered that it was my outer DIV that was moving, which is why the
image appeared to be not centering properly.
I ended up putting
style='padding-left:auto;padding-right:auto;text-align:center;'

in the containing DIV.
The padding makes standards compliant browsers center, while IE responds to
the text-align.

Thanks again.

Ron





Reply With Quote
  #4  
Old   
Bergamot
 
Posts: n/a

Default Re: Image Centering Solved - 01-19-2009 , 07:58 PM




Ron Barnett wrote:
Quote:
I ended up putting
style='padding-left:auto;padding-right:auto;text-align:center;'

in the containing DIV.
The padding makes standards compliant browsers center, while IE responds to
the text-align.
Sounds like you're triggering quirks mode. Use a strict DOCTYPE and
standards mode and you won't have those problems.

--
Berg


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.