CSS Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsWeb DesignCSS Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old July 21st, 2004, 10:11 PM
timholgate timholgate is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 4 timholgate User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Exclamation position:absolute relative to user-defined origin?

I am trying to run a javascript that constructs a menu but must use absolute positioning. I can put the menu correctly where I want it by setting parameters of left and top from origin. However... this doesn't work too well for a page consisting of 800px tables centered for looking good in any resolution 800x600 and up. So I was wondering if it is possible to use absolute positioning and define an origin using anchor tags or something like that. Any help please?

Reply With Quote
  #2  
Old July 22nd, 2004, 01:45 AM
TheJim01's Avatar
TheJim01 TheJim01 is offline
Coconuts migrate?
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Feb 2004
Location: http://middle.nowhere.com
Posts: 1,894 TheJim01 User rank is General 3rd Grade (Above 100000 Reputation Level)TheJim01 User rank is General 3rd Grade (Above 100000 Reputation Level)TheJim01 User rank is General 3rd Grade (Above 100000 Reputation Level)TheJim01 User rank is General 3rd Grade (Above 100000 Reputation Level)TheJim01 User rank is General 3rd Grade (Above 100000 Reputation Level)TheJim01 User rank is General 3rd Grade (Above 100000 Reputation Level)TheJim01 User rank is General 3rd Grade (Above 100000 Reputation Level)TheJim01 User rank is General 3rd Grade (Above 100000 Reputation Level)TheJim01 User rank is General 3rd Grade (Above 100000 Reputation Level)TheJim01 User rank is General 3rd Grade (Above 100000 Reputation Level)TheJim01 User rank is General 3rd Grade (Above 100000 Reputation Level)TheJim01 User rank is General 3rd Grade (Above 100000 Reputation Level)TheJim01 User rank is General 3rd Grade (Above 100000 Reputation Level)TheJim01 User rank is General 3rd Grade (Above 100000 Reputation Level)TheJim01 User rank is General 3rd Grade (Above 100000 Reputation Level)TheJim01 User rank is General 3rd Grade (Above 100000 Reputation Level)  Folding Points: 67725 Folding Title: Intermediate FolderFolding Points: 67725 Folding Title: Intermediate FolderFolding Points: 67725 Folding Title: Intermediate FolderFolding Points: 67725 Folding Title: Intermediate Folder
Time spent in forums: 2 Weeks 5 Days 10 h 4 m 38 sec
Reputation Power: 1173
You probably have a div or something defining your main content area, right? Like:
PHP Code:
<body style="text-align: center;">

<
div style="width: 800px; margin-left: auto; margin-right: auto;">
This is your main content area
</div>

</
body


Absolute positioning is relative to the last positioned element, with its "last resort" being the main body of the document. So, you can position your main content area without really moving it by using realtive psoitioning--which means relative to where it would normally be:
PHP Code:
<body style="text-align: center;">

<
div style="width: 800px; margin-left: auto; margin-right: auto; position: relative; top: 0px; left: 0px;">
This is your main content area.
</
div>

</
body


The "position: relative; top: 0px; left: 0px;" means that it will be moved 0px from teh top and 0px from the left of where it would normally be placed. Now, you can put your absolutely positioned element (in my example, a div) inside your main content div, and it will be absolutely positioned INSIDE the div, relative to THAT position, as opposed to the main window.
PHP Code:
<body style="text-align: center;">

<
div style="width: 800px; margin-left: auto; margin-right: auto; position: relative; top: 0px; left: 0px;">
This is your main content area.

<
div style="width: 100px; position: absolute; top: 100px; left: 100px;">
This div will be 100px from the top and 100px from the left of the top left corner of your main content div.
</
div>

</
div>

</
body


I hope that makes sense. Maybe others can explain it more clearly.
__________________

Proud member of the T.S.N.B.U.F.L (tables should not be used for layout) alliance.

"Only use elements for their intended purpose. You wouldn't try to make coffee with a telephone, would you?" -Me

Reply With Quote
  #3  
Old July 22nd, 2004, 01:49 AM
kk5st's Avatar
kk5st kk5st is online now
Thanks Johnny Hart (BC) R.I.P.
Dev Shed Demi-God (4500 - 4999 posts)
 
Join Date: May 2003
Location: Dallas
Posts: 4,659 kk5st User rank is Brigadier General (60000 - 70000 Reputation Level)kk5st User rank is Brigadier General (60000 - 70000 Reputation Level)kk5st User rank is Brigadier General (60000 - 70000 Reputation Level)kk5st User rank is Brigadier General (60000 - 70000 Reputation Level)kk5st User rank is Brigadier General (60000 - 70000 Reputation Level)kk5st User rank is Brigadier General (60000 - 70000 Reputation Level)kk5st User rank is Brigadier General (60000 - 70000 Reputation Level)kk5st User rank is Brigadier General (60000 - 70000 Reputation Level)kk5st User rank is Brigadier General (60000 - 70000 Reputation Level)kk5st User rank is Brigadier General (60000 - 70000 Reputation Level)kk5st User rank is Brigadier General (60000 - 70000 Reputation Level)kk5st User rank is Brigadier General (60000 - 70000 Reputation Level)kk5st User rank is Brigadier General (60000 - 70000 Reputation Level) 
Time spent in forums: 1 Month 3 Days 11 h 50 m 47 sec
Reputation Power: 687
Absolute positioned (AP) elements are referenced to their nearest positioned ancestor. If your js is writing th AP element, I'm guessing you should have it inline so that it is written as a child of the desired container. Alternatively, write the menu directly in html with {display:none;}, using js to toggle the display property.

I say I'm guessing because I won't use javascript or any plugin (eg. Flash) for basic functionality, so I have no first-hand knowledge.

cheers,

gary
__________________
There are those who manage to build a web site without knowing what they're doing; thereby proving to themselves they do, indeed, know what they're doing.

My html and css workshop, demos and tutorials.
Ask a better question, get a better answer.

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignCSS Help > position:absolute relative to user-defined origin?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT