/    Sign up×
Community /Pin to ProfileBookmark

Position a Semi-Transparent Div on Top of Another

Is it possible to position a DIV on top of another?

I’m building something whereby the content of a DIV needs to be grayed-out based on user interaction, but with the content still being semi-visible. Very similar to an AJAX Modal Popup.

I’ve got the semi-transparency working and the DIV displaying/hiding as needed, but the problem is the positioning of it.

to post a comment
CSS

4 Comments(s)

Copy linkTweet thisAlerts:
@khorinshizucorFeb 03.2011 — If you're using position:relative and/or position:absolute where needed then you can use z-index. The numbers determine how they're stacked. So say if #div2 needs to be on top of #div1, add the following to each ID selector:

[CODE]
#div1 { z-index:1; }
#div2 { z-index:2; }
[/CODE]


The highest number will be the top. You can see how it works here.
Copy linkTweet thisAlerts:
@dch3authorFeb 03.2011 — But how do I get the div's on top of themselves to begin with in terms of position, top, left etc.?
Copy linkTweet thisAlerts:
@khorinshizucorFeb 03.2011 — Try "position:absolute" for both divs and the z-index values I suggested and see how that works for you.
Copy linkTweet thisAlerts:
@dch3authorFeb 08.2011 — Actually did the trick. I was using absolute:fixed for the div providing the grey-over background.
×

Success!

Help @dch3 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 5.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: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

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

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...