User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the HTML and CSS section within the Web Development category of DaniWeb, a massive community of 455,970 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,773 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our HTML and CSS advertiser: Lunarpages Web Hosting
Views: 3101 | Replies: 8
Reply
Join Date: Jun 2006
Posts: 27
Reputation: jetru is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 0
jetru jetru is offline Offline
Light Poster

overlapping divs

  #1  
Nov 25th, 2007
I have two divs which both have backgrounds in my CSS properties.

Unfortunately, div2's background overlaps div1's background. But I want it the other way around. In other words, I want div1's background over div2's. I've tried z-index but it didn't work. How do i solve this?
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jan 2007
Posts: 2,604
Reputation: MidiMagic is on a distinguished road 
Rep Power: 7
Solved Threads: 119
MidiMagic's Avatar
MidiMagic MidiMagic is offline Offline
Posting Maven

Re: overlapping divs

  #2  
Nov 25th, 2007
You must render the div you want on top last. This means that the div to be on top must be inside the other div in the HTML file.

HTML is not normally supposed to place objects on top of each other. Objects are normally supposed to have their own places on the page without overlap.
Daylight-saving time uses more gasoline
Reply With Quote  
Join Date: Jun 2006
Posts: 27
Reputation: jetru is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 0
jetru jetru is offline Offline
Light Poster

Re: overlapping divs

  #3  
Nov 26th, 2007
But I would like only a part of the div to overlap the other div...not the whole thing...
Reply With Quote  
Join Date: Jan 2007
Posts: 2,604
Reputation: MidiMagic is on a distinguished road 
Rep Power: 7
Solved Threads: 119
MidiMagic's Avatar
MidiMagic MidiMagic is offline Offline
Posting Maven

Re: overlapping divs

  #4  
Nov 28th, 2007
What do these divs contain. Depending on the content, there may be other ways to do this.
Daylight-saving time uses more gasoline
Reply With Quote  
Join Date: Nov 2007
Posts: 4
Reputation: cashu is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
cashu cashu is offline Offline
Newbie Poster

Re: overlapping divs

  #5  
Dec 1st, 2007
i had the same problem.
thanks
cashu
http://tech-unite.com/forum/viewtopic.php?f=5&t=10
Reply With Quote  
Join Date: Jun 2004
Posts: 231
Reputation: cmills83 is an unknown quantity at this point 
Rep Power: 5
Solved Threads: 0
cmills83 cmills83 is offline Offline
Posting Whiz in Training

Re: overlapping divs

  #6  
Dec 3rd, 2007
z-index property with positioning

divname { position:absolute; z-index:1; }
divname2 { position:absolute; z-index:2; }
probably in a container div
Reply With Quote  
Join Date: Jun 2004
Posts: 231
Reputation: cmills83 is an unknown quantity at this point 
Rep Power: 5
Solved Threads: 0
cmills83 cmills83 is offline Offline
Posting Whiz in Training

Re: overlapping divs

  #7  
Dec 3rd, 2007
then position with top:xxpx; left:xxpx; or right or bottom, etc.
Reply With Quote  
Join Date: Jun 2004
Location: Hemet, CA
Posts: 429
Reputation: FC Jamison is on a distinguished road 
Rep Power: 5
Solved Threads: 18
Colleague
FC Jamison's Avatar
FC Jamison FC Jamison is offline Offline
Posting Pro in Training

Re: overlapping divs

  #8  
Dec 6th, 2007
By default, elements that are formatted later in an HTML document are stacked on top of earlier elements. In addition, elements placed with CSS positioning are stacked on top of elements that are not. To specify a different stacking order, use the style

z-index: value

where value is a positive or negative integer, or the keyword "auto". Objects are stacked based on their z-index values, with the highest z-index values placed on top.

The z-index style only works for elements that are placed with absolute positioning. Also, an element's z-index value determines its position relative only to other elements that share a common parent.

So a container div enveloping the other two divs is required.

I hope that helps...stacking objects can get tricky sometimes.
Reply With Quote  
Join Date: Jun 2006
Posts: 27
Reputation: jetru is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 0
jetru jetru is offline Offline
Light Poster

Re: overlapping divs

  #9  
Dec 6th, 2007
All these work just fine in firefox. IE just refuses to accept any of these! I tried everything!
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb HTML and CSS Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the HTML and CSS Forum

All times are GMT -4. The time now is 9:13 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC