Help centering a layer
How do you center a layer? I am trying to use drop down navigation boxes. I put everything on a layer and then coded the dropdown navigation boxes. It looks good in 800x600 but I would like it to be centered in 1024x768.
You can check it out here:
http://www.clicknetsolutions.com/index2.shtml
The header and footer are pulled in using SSI. All I need to do is get it centered in 1024x768 and it will be just the way I want it. Your input and help is greatly appreciated. Andrew
ROB posted this at 00:29 — 22nd April 2002.
They have: 447 posts
Joined: Oct 1999
to center a layer set the layer left to 1/2 the page width - 1/2 the layer width.
this is just off the top of my head and surely wrong, but you get the idea...
body onload="document.getElementById("layerName").left = (screen.width/2) - (document.getElementById("layerName").width/2)";
detox posted this at 14:23 — 23rd April 2002.
They have: 571 posts
Joined: Feb 2001
this is ripped of irt.org !
too late to look i my own code library!
[php]
<script language="JavaScript"></script>
Some Text
Sed ut perspiciatis unde omnis iste natus error sit
voluptatem accusantium doloremque laudantium, totam
rem aperiam, eaque ipsa ab illo inventore veritatis
et quasi architecto beatae vitae dicta sunt explicabo.
Nemo enim ipsam voluptatem quia voluptas sit aspernatur
aut odit aut fugit, sed quia consequuntur magni dolores
eos qui ratione voluptatem sequi nesciunt. Neque porro
quisquam est qui do lorem ipsum quia dolor sit amet,
consectetur, adipisci velit, sed quia nonnumquam eiusmodi
tempora incidunt ut labore et dolore magnam aliquam
quaerat voluptatem. Ut enim ad minima veniam, quia
nostrum exercitationem ullam corporis suscipit laboriosam,
nisi ut aliquid ex ea commodi consequatur? Quis autem vel
eum iure reprehenderit qui in ea voluptate velit esse quam
nihil molestiae consequatur, vel illum qui dolorem eum
fugiat quo voluptas nulla pariatur? At vero eos et
accusamus et iusto odio dignissimos ducimus qui blanditiis
praesentium voluptatum deleniti atque corrupti quos dolores
et quas molestias excepturi sint occaccati cupiditate
non provident, similique sunt in culpa qui officia deserunt
mollitia animi, id est laborum et dolorum fuga. Et harum
quidem rerum facilis est et expedita distinctio. Nam libero
tempore, cum soluta nobis est eligendi optio cumque nihil
impedit quo minus id quod maxime placeat facere possimus,
omnis dolor repellendus. Temporibus autem quibusdam et
aut officiis debitis aut rerum necessitatibus saepe eveniet
ut et voluptates repudiandae sint et molestiae non recusandae.
Itaque earum rerum hic tenetur a sapiente delectus
ut aut reiciendis voluptatibus maiores alias consequatur aut
perferendis doloribus asperiores repellat.
[php]
dk01 posted this at 20:14 — 23rd April 2002.
He has: 516 posts
Joined: Mar 2002
Detox I was wondering if you tested that code in NS4 because I thought that a layers width and height would snap to its contents in NS4 unless otherwise specifies. I could be wrong.
-dk
Mike Feury posted this at 23:18 — 3rd May 2002.
They have: 48 posts
Joined: May 2002
Can't see your page, but if your layer isn't fixed-width, then specifying percentage width & left/right will do it. Say width: 80%; left: 10%; right: 10%.
If it's fixed width, then I think setting margin-left and margin-right to auto will center it.
Mike
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.