Not Centering in Opera

Reply

Join Date: Jan 2009
Posts: 22
Reputation: EvilOrange is an unknown quantity at this point 
Solved Threads: 0
EvilOrange EvilOrange is offline Offline
Newbie Poster

Not Centering in Opera

 
0
  #1
Feb 4th, 2009
Hi,

I have a website in development and i've made it centered regardless of width of the viewing browser window (eg. the browser is 1000px wide and the content is 600px wide and is centered with 200px each side) by using div's.

Now it works perfectly in FF, IE and WebKit (Safari, Chrome etc) but trying to open in Opera it is aligned left...

Now i know opera doesn't recognize text-align: center (how i'm centering the "wrapper" div) so my question really is...does anyone know of a work around for this typr of centering in Opera?

Thanks
Reply With Quote Quick reply to this message  
Join Date: Jan 2009
Posts: 1,346
Reputation: almostbob has a spectacular aura about almostbob has a spectacular aura about 
Solved Threads: 163
almostbob's Avatar
almostbob almostbob is offline Offline
Nearly a Posting Virtuoso

Re: Not Centering in Opera

 
0
  #2
Feb 4th, 2009
Originally Posted by EvilOrange View Post
Hi,

I have a website in development and i've made it centered regardless of width of the viewing browser window (eg. the browser is 1000px wide and the content is 600px wide and is centered with 200px each side) by using div's.

Now it works perfectly in FF, IE and WebKit (Safari, Chrome etc) but trying to open in Opera it is aligned left...

Now i know opera doesn't recognize text-align: center (how i'm centering the "wrapper" div) so my question really is...does anyone know of a work around for this typr of centering in Opera?

Thanks
Its not going to work in any browser, except your own.
open a window less than full screen and your page is shifted right, out of the visible area, click a link and the new page is shifted right out of the visible area. No.
images and borders, sized in pixels
all other elements, sized in ems or %
then the visible page will properly adjust,
Your divs should be something like 10% 80% 10% which will scale, and increase the usable area by 1/3

opera has a few quirks
for the vanishing div try sticking something in it
<div> &nbsp; </div>
still 'blank' but may display differently
check also the styles, different browsers throw away the entire style if the definitions are 'wrong'
Last edited by almostbob; Feb 4th, 2009 at 9:38 am.
Failure is not an option It's included free
If at first you dont succeed, join the club
Of course its always in the last place you look, you dont keep looking after you find it

Please mark solved problems, solved
Reply With Quote Quick reply to this message  
Join Date: Jan 2009
Posts: 22
Reputation: EvilOrange is an unknown quantity at this point 
Solved Threads: 0
EvilOrange EvilOrange is offline Offline
Newbie Poster

Re: Not Centering in Opera

 
0
  #3
Feb 5th, 2009
sorry don't think i was total implicit...

HTML and CSS Syntax (Toggle Plain Text)
  1. #wrapper {
  2. text-align: center;
  3. }
  4.  
  5. #innerwrap{
  6. text-align: left;
  7. margin: 0 auto;
  8. width: 600;
  9. }

is what i'm using to center the content....
with all content being inside the innerwrapper
Reply With Quote Quick reply to this message  
Join Date: Jan 2009
Posts: 1,346
Reputation: almostbob has a spectacular aura about almostbob has a spectacular aura about 
Solved Threads: 163
almostbob's Avatar
almostbob almostbob is offline Offline
Nearly a Posting Virtuoso

Re: Not Centering in Opera

 
0
  #4
Feb 5th, 2009
the width of #innerwrap could be, throwing browsers off
without a dimension IE firefox opera render differently
IE assumes px
firefox throws it away(but 0 auto margin setting would make it work anyway in firefox)
opera goes funky

  1. body { text-align:center; }
  2. #innerwrap{ text-align: left;
  3. margin: 0 auto;
  4. width: 60%; }
works in opera IE Firefox
I set the body, you set outer wrap, same thing
Last edited by almostbob; Feb 5th, 2009 at 10:07 am.
Failure is not an option It's included free
If at first you dont succeed, join the club
Of course its always in the last place you look, you dont keep looking after you find it

Please mark solved problems, solved
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 76
Reputation: ccube921 is an unknown quantity at this point 
Solved Threads: 6
ccube921 ccube921 is offline Offline
Junior Poster in Training

Re: Not Centering in Opera

 
0
  #5
Feb 5th, 2009
I'm not sure that that will always work but I use this method to center objects, Position the wrap div left: 50%; this will set the left corner of the div to be in the exact center of the page, then set a negative margin to be half the width of the content (e.g. If your content is 300px your margin would be -150) which will move the content back to the left, centering it exactly. Your end code will look something like this
#wrap
{
Position:fixed;
left:50%;
width: 300px
margin: -Half of your content width (in this case -150px) ;
If I have been helpful add to my reputation!
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 101
Reputation: ingeva is an unknown quantity at this point 
Solved Threads: 9
ingeva ingeva is offline Offline
Junior Poster

Re: Not Centering in Opera

 
0
  #6
Feb 6th, 2009
I had the same "problem" when testing a site with Opera.

The reason is that align:center is not supported for block objects. This conforms with W3C standards, so Opera is doing it right and the others do not.

Use margin:0 auto; for centering objects,
and text-align:center; can be used to center the contents of a block.

Note that even if you use text-align:center; for a block object, it may not be centered unless you ALSO specify margin:0 auto; for that object.

In these cases, Opera, and in my experience FireFox 3, does this the way it was intended.

Note that for instance <div align:center> is not supported at all except in quirks mode. This is because the layout and style should not be specified in the HTML. That's for the CSS.
Last edited by ingeva; Feb 6th, 2009 at 9:06 am.
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 10
Reputation: dflor is an unknown quantity at this point 
Solved Threads: 0
dflor dflor is offline Offline
Newbie Poster

Re: Not Centering in Opera

 
0
  #7
Feb 7th, 2009
I think that in css margin-left:auto; margin-right:auto (margin: 0 auto) works fine, for the main table or div, instead of margin-left: 200px.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the HTML and CSS Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC