Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Overlay one Div over another's padding, using z-index and position relative to parent Div?

Posted on 2008-10-15
3
Medium Priority
?
2,899 Views
Last Modified: 2013-11-19
Hi,

 I'm trying to get two Divs to overlap and the top one to be placed over the bottom ones Padded area. Tried the code below but obviously this aligns the top Div to the browser.

How would I position it relative to the bottom Div? As a side not I also need to keep the current layout for  #Background and #mainCont as is.

Thanks.
<style type="text/css">
<!--
html, body {
	margin: 0 auto;
}
 
#background {
	text-align: center;
	width: 1680px auto;
	height:100%;
	background-color: #FF6600 ;
}
#mainCont {
	text-align:left;
	margin: 0 auto;
	width: 1300px;
}
#test1 {
	padding: 20px;
	background-color:#00FF33;
	width:200px;
	height:60px;
}
#test2 {
	background-color:#3399CC;
	width:40px;
	height:20px;
}
 
.overlap {
position:absolute;
left:20px;
top:0px;
z-index:1;
}
-->
</style>
 
 
 
<div id="background">
  <div id="mainCont">  
    <div id="test1">test1</div>
    <div class="overlap" id="test2">test2</div>
  </div>
</div>

Open in new window

0
Comment
Question by:sany101
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 43

Accepted Solution

by:
David S. earned 2000 total points
ID: 22720128
Give #mainCont position:relative

More information: http://www.dynamicsitesolutions.com/css/layout-techniques/#abs_rel_pos
0
 
LVL 1

Expert Comment

by:Rapturer
ID: 22720226
Hi Sany,

This one is easy...you have your overlapped div content within another div that is not.

This will get it done for you:

#test2 {
        background-color:#3399CC;
        width:40px;
        height:20px;
        left:120px;
        top:30px;
           
}
0
 

Author Comment

by:sany101
ID: 22720422
Thanks Kravimir you don't know how long I spent scratching my head on this one.... Works a dream and thanks for the link info.

Repturer that didn't seem to work for me but thanks for the imput.

If only they where all this simple.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
In this tutorial viewers will learn how to style a decorative dropcap for the first letter in a paragraph using CSS. In CSS, create a new paragraph class by typing "p.fancy": Then, to style only the first letter of the first sentence, include the ps…
In this tutorial viewers will learn how to style rounded corners for elements in CSS using the border-radius property Begin with a normal styled element such as a div: To style all four corners of the div to be the same degree of roundness, use the …

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question