HighDots Forums  

Centering a layer in the window with CSS

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


Discuss Centering a layer in the window with CSS in the Cascading Style Sheets forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Peter Altenberg
 
Posts: n/a

Default Centering a layer in the window with CSS - 11-18-2004 , 05:49 PM






is there some way to make the positioning of a layer (div) so that it
is centered in the window. so even when you resize the window it stays
centered? i would like to do this with CSS just like you can with
tables.

thanks,
~peter

Reply With Quote
  #2  
Old   
Chris Leipold
 
Posts: n/a

Default Re: Centering a layer in the window with CSS - 11-19-2004 , 02:34 AM






Hi,

Quote:
is there some way to make the positioning of a layer (div) so that it
is centered in the window. so even when you resize the window it stays
centered? i would like to do this with CSS just like you can with
tables.
First, a layer is not a div. (There once was a layer-element, so don't
mix them up).

Centering a div should work like this:
<div style="margin-left:auto;margin-right:auto;">[...]</div>

Chris


Reply With Quote
  #3  
Old   
Els
 
Posts: n/a

Default Re: Centering a layer in the window with CSS - 11-19-2004 , 02:39 AM



Chris Leipold wrote:

Quote:
Hi,

is there some way to make the positioning of a layer (div)
so that it is centered in the window. so even when you
resize the window it stays centered? i would like to do
this with CSS just like you can with tables.

First, a layer is not a div. (There once was a
layer-element, so don't mix them up).

Centering a div should work like this:
div
style="margin-left:auto;margin-right:auto;">[...]</div
That doesn't work in IE5 for Windows.
http://locusmeus.com/html-css/centeringpage.html

--
Els
http://locusmeus.com/
Sonhos vem. Sonhos vão. O resto é imperfeito.
- Renato Russo -


Reply With Quote
  #4  
Old   
Chris Leipold
 
Posts: n/a

Default Re: Centering a layer in the window with CSS - 11-19-2004 , 02:48 AM



Hi,

Quote:
That doesn't work in IE5 for Windows.
http://locusmeus.com/html-css/centeringpage.html
omg. Kick IE5 for windows. Use Conditional Comments to kick IE5-users to
www.getfirefox.com


Reply With Quote
  #5  
Old   
Els
 
Posts: n/a

Default Re: Centering a layer in the window with CSS - 11-19-2004 , 02:56 AM



Chris Leipold wrote:

Quote:
Hi,

That doesn't work in IE5 for Windows.
http://locusmeus.com/html-css/centeringpage.html

omg. Kick IE5 for windows. Use Conditional Comments to kick
IE5-users to www.getfirefox.com
Conditional Comments? As in: Opera being kicked too, just cause
it identifies as IE? Nah, I prefer to make a simple adjustment
to include those users :-)

--
Els
http://locusmeus.com/
Sonhos vem. Sonhos vão. O resto é imperfeito.
- Renato Russo -


Reply With Quote
  #6  
Old   
Chris Leipold
 
Posts: n/a

Default Re: Centering a layer in the window with CSS - 11-19-2004 , 03:02 AM



Hi Els,

Quote:
Conditional Comments? As in: Opera being kicked too, just cause
it identifies as IE? Nah, I prefer to make a simple adjustment
to include those users :-)
Opera does not recognize CCs. You can therefore use them savely. And you
should read what they are and what they do.

Chris


Reply With Quote
  #7  
Old   
Cezar
 
Posts: n/a

Default Re: Centering a layer in the window with CSS - 11-20-2004 , 05:55 AM



Peter Altenberg napisał(a):

Quote:
is there some way to make the positioning of a layer (div) so that it
is centered in the window. so even when you resize the window it stays
centered? i would like to do this with CSS just like you can with
tables.
This may help You:
http://css-discuss.incutio.com/?page...ngBlockElement

--
Regards,
Cezar


Reply With Quote
  #8  
Old   
PDannyD
 
Posts: n/a

Default Re: Centering a layer in the window with CSS - 11-20-2004 , 06:44 AM



On Fri, 19 Nov 2004 09:48:28 +0100, Chris Leipold <cleipold (AT) dietzk (DOT) de>
wrote in message <305qaoF2t1f2tU2 (AT) uni-berlin (DOT) de>:

Quote:
Hi,

That doesn't work in IE5 for Windows.
http://locusmeus.com/html-css/centeringpage.html
omg. Kick IE5 for windows. Use Conditional Comments to kick IE5-users to
www.getfirefox.com
:-)

Or something more polite like "You are using an out-dated browser. It is
recommended you download the latest patches and updates for a better
browsing experience and greater security and stability.
Alternatively, have you considered <insert-favourite-browser-name-here>?"

--
FZS600 - Silver/Black
GS125 - Black/Rust
Ford 100E Prefect - Black, naturally
Whisky - Aberlour Cask Strength


Reply With Quote
  #9  
Old   
Frances Del Rio
 
Posts: n/a

Default Re: Centering a layer in the window with CSS - 11-20-2004 , 12:21 PM



Peter Altenberg wrote:

Quote:
is there some way to make the positioning of a layer (div) so that it
is centered in the window. so even when you resize the window it stays
centered? i would like to do this with CSS just like you can with
tables.
I know some people will yell and scream that this is not orthodox way to
do it, but this is what I do when I need to center a div and it always
works (IE and Netscape anyway..) it does involve tables, but it's the
only sure way I have found to center divs, take it or leave it:

http://www.francesdelrio.com/index_center_div.html

this is what I do:

<div id="stuff" style="position:absolute; top:80px; left:0px">
<table border=1 cellpadding=0 cellspacing=0 width="100%">
<tr><td align=center>

content of div goes here...
(which can be another table with whatever width you want.. and it
will be centered..)

</td></tr></table>
</div>

I left table borders on so you better see what I did.. I'm afraid it
doesn't work in Opera b/c Opera does not respect table wdth of 100% (so
if I do want my pg to work in Opera I do a diff. version where div is
not strictly centered (or do it w/tables-only for Opera) and direct pg
to diff. version with a browser-detection script..

if (navigator.userAgent.indexOf('Opera') != -1 ) {
location = "version_of_pg_for_Opera.html"
}

good luck..... HTH... Frances







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 - 2008, Jelsoft Enterprises Ltd.