Solved

how can you stop relative - absolute div collapse

Posted on 2013-01-10
6
760 Views
Last Modified: 2013-01-15
How can I stop the div #banner_ad_wrapper from collapsing.  The reason I am using position absolute on .banner_ad is I want to stack them on top of each other.  Should I be doing this a different way.  Thanks

#banner_ad_wrapper {
	position:relative;
	margin-top:20px;
}
.banner_ad {
	width:920px;
	margin-left:20px;
	position:absolute;
	top:0;
}

<div id="banner_ad_wrapper">
<div  class="banner_ad">
  <img src="images/010713_JewelryHandbagWalletSale_site.jpg" width="920" />
</div>
<div class="banner_ad">
  <img src="images/011013_save10whenyouspend100v4.jpg" width="920"/>
  </div>
</div>

Open in new window

0
Comment
Question by:Luey
  • 4
6 Comments
 
LVL 12

Expert Comment

by:jessegivy
ID: 38764224
Try this:

#banner_ad_wrapper {
      position:relative;
      margin-top:20px;
        overflow:visible;
}
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 38764475
If that help... lucky.  If not a link to the page or the code would give us enough information to provide a full solution.  As it stands you have no z-index; so how do you intend to manage the stacking order?

Cd&
0
 

Author Comment

by:Luey
ID: 38764859
The stacking order is not relevant I will be using javascript to toggle show and hide the divs with the class banner_ads.  I just want to know how to put one div on top of another.  If you use a parent div positioned relative and a sibling div positioned absolute then the parent collapses.  So how can you stack divs on top of each other but keep the rest of you content to flow in a normal fashion.
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

by:Luey
ID: 38764866
overflow:visible;  did not work.
0
 

Accepted Solution

by:
Luey earned 0 total points
ID: 38765010
I have found that when you position something absolute it will always take it out of the normal flow of content therefore it will always collapse the parent if a height is not set for the parent.  So I have set a height for my parent div and solved the problem.

#banner_ad_wrapper {
	position:relative;
	margin-top:20px;
	height:300px;	
}

Open in new window

0
 

Author Closing Comment

by:Luey
ID: 38777591
I did not get an answer that solved the problem.  However from other resources i found the answer.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
In this Micro Tutorial users will learn how to embed custom fonts into websites using @font-face in CSS Select a font: Ensure the EULA allows you to use @font-face: Download the font: Get the browser-compatible files you need: Edit your CSS       - Name …
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …

747 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now