Board index PBase HTML and Style Sheets How to center this element in IE

HTML and Style Sheets

How to center this element in IE

Customize your galleries.
mardoli
 
Posts: 589

How to center this element in IE

Post Sun Aug 10, 2008 5:51 pm


Hello!
I’m messing around with style-sheet, I have not any serious knowledge, but I use an empirical method...I try and try again and look at what happens...Sometimes it work.
In this gallery
http://www.pbase.com/mardoli/dame_du_lac
I’m stuck with
DIV.galleryheader
In Firefox I could get it centred using the command
margin-right : auto;
margin-left : auto;
But in IE it looked all on the left.
So I corrected the script empirically like that
margin-right : auto;
margin-left : 355px;
Adding a value for margin-left a little at random and it seemed to center the table.
But I see it’s not exactly centred and I’m also afraid it can work only in my screen or similar.
I’d be very grateful if someone could teach me how to do exactly.
Many thanks in advance
Marisa
ImageImage
"Arguments are to be avoided; they are always vulgar and often convincing."
~Oscar Wilde~

flemmingbo
 
Posts: 435
Location: Denmark, Copenhagen

Re: How to center this element in IE

Post Sun Aug 10, 2008 6:58 pm


Hi Marisa,

You were on the right path - the correct way is this

DIV.galleryheader
{
margin-right : auto;
margin-left : auto;
}

That works fine in good browsers. As you've discovered the stupid IE doesn't understand this so we have to utilize a bug in IE.
In IE if you add

text-align:center;

to the BODY then IE will automatically center any child DIVs....weird bug but it works.

So in the top of your CSS where the BODY part is, add text-align:center;

and change galleryheader to:

DIV.galleryheader
{
margin-right : auto;
margin-left : auto;
}

That should now work in both browsers. If you have any other DIVs where the text is now centered because we added that bit to the BODY, just counter it in that specific class in CSS with text-align:left;

Hope this works,

all the best,

Flemming
Flemming Bo Jensen Photography
Gallery: http://www.pbase.com/flemmingbo
My photography blog: http://flemmingbo.wordpress.com

mardoli
 
Posts: 589

Re: How to center this element in IE

Post Sun Aug 10, 2008 7:30 pm


Thank you, Flemming!
It works perfectly...I would have never thought of that myself...
Thank you so much!
Marisa
ImageImage
"Arguments are to be avoided; they are always vulgar and often convincing."
~Oscar Wilde~

flemmingbo
 
Posts: 435
Location: Denmark, Copenhagen

Re: How to center this element in IE

Post Mon Aug 11, 2008 7:04 am


No worries, glad to help and glad it worked.

During the couple of months spent creating my new layout I learned A LOT about the many annoying bugs in IE and how to do work-arounds. A lot of time that could have been spent better if Microsoft created a better browser!

regards,

Flemming
Flemming Bo Jensen Photography
Gallery: http://www.pbase.com/flemmingbo
My photography blog: http://flemmingbo.wordpress.com


Board index PBase HTML and Style Sheets How to center this element in IE

Who is online

Users browsing this forum: ClaudeBot and 1 guest