/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] Relative positioned DIV

Hi

I have a menu DIV which I need to be positioned relative to another element. All the content on the site is DIV-based, and held in a container DIV which has auto margins, so I cant position the menu DIV absolutely because the content slides when the window is resized.

Can anyone help me with what HTML and CSS I need to attach the menu DIV to the element. To clarify this will be like a drop menu. I need the menu DIV to lay over all other content. No flashy JavaScript effects I just need the menu DIV to stick with the rest of the content.

[upl-file uuid=e1ce675d-2c76-4866-9d7b-05bb3c42648d size=6kB]Untitled-1.gif[/upl-file]

to post a comment
CSS

3 Comments(s)

Copy linkTweet thisAlerts:
@WebJoelDec 01.2007 — ...and held in a container DIV which has auto margins, so I cant position the menu DIV absolutely because the content slides when the window is resized...[/QUOTE] Even with margin:0 auto (which is margin-left:auto; and margin-right:auto), if that div is "position:relative;", the drop-down can be "position:absolute;" and it remains 'attached' to that exact point of the relative-positioned parent, -even if the browser is re-sized. It should not be affected by 'margin:auto'.

Can we see your code?
Copy linkTweet thisAlerts:
@chris_farsightauthorDec 01.2007 — Thanks, that solved it. I had the menu div positioned as relative but not the containing div. Setting both as relative sorted it fine.

many thanks
Copy linkTweet thisAlerts:
@WebJoelDec 01.2007 — The 'default position' is always "static". Often, stating "position:relative;" does wonders. ?
×

Success!

Help @chris_farsight spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...