Go Back   CodingForums.com > :: Client side development > HTML & CSS

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 05-22-2010, 04:11 PM   PM User | #1
johnmerlino
Regular Coder

 
Join Date: Oct 2009
Posts: 189
Thanks: 38
Thanked 3 Times in 3 Posts
johnmerlino is an unknown quantity at this point
Overflow auto doesn't overflow?

Hey all,

I'm just curious. Overflow auto typically works with p, h1, and other block level elements that occupy space in the normal flow. However, when I try to have it overflow divs (which I know are empty block level elements), I still specify a styling to those divs, speciically a width and height (so now they occupy space), yet the overflow: auto for the container div still doesn't overflow:
Code:
	<div id="container">
		<div id="s01"></div>
		<div id="s02"></div>
		<div id="s03"></div>
		<div id="s04"></div>
		<div id="s05"></div>
	        <div id="s06"></div>
		<div id="s07"></div>
		<div id="s08"></div>
	</div>

#container {
	position: relative;
	left: 100px;
	width: 580px;
	border: 1px solid #f00;
	overflow: auto;
}

#s01 {
	position:absolute;
	left:19px;
	top:23px;
	width:50px;
	height:50px;
	border: 2px solid #000;
}
#s02 {
	position:absolute;
	left:138px;
	top:23px;
	width:50px;
	height:50px;
	border: 2px solid #000;
}
#s03 {
	position:absolute;
	left:256px;
	top:23px;
	width:50px;
	height:50px;
	border: 2px solid #000;
}
#s04 {
	position:absolute;
	left:375px;
	top:23px;
	width:50px;
	height:50px;
	border: 2px solid #000;
}
#s05 {
	position:absolute;
	left:493px;
	top:23px;
	width:50px;
	height:50px;
	border: 2px solid #000;
}

#s06 {
	position:absolute;
	left:19px;
	top:114px;
	width:50px;
	height:50px;
	border: 2px solid #000;
}
#s07 {
	position:absolute;
	left:138px;
	top:117px;
	width:50px;
	height:50px;
	border: 2px solid #000;
}
#s08 {
	position:absolute;
	left:256px;
	top:117px;
	width:50px;
	height:50px;
	border: 2px solid #000;
}
I am missing a rule here? Thanks for any response. Also, do you think it is better to dynamically build those divs in javascript on page load?
johnmerlino is offline   Reply With Quote
Old 05-22-2010, 04:39 PM   PM User | #2
Excavator
Master Coder


 
Excavator's Avatar
 
Join Date: Dec 2006
Location: Alaska
Posts: 9,410
Thanks: 22
Thanked 1,765 Times in 1,749 Posts
Excavator has a spectacular aura aboutExcavator has a spectacular aura aboutExcavator has a spectacular aura about
Hello johnmerlino,
Your use of absolute positioning removes those divs, s01 thru 08, from the normal flow of the document. That means #container doesn't see anything to enclose.

You will need to give #container a height for this to work.
Read about the pitfalls of absolute positioning here.
__________________
Validate often DURING development - Use it like a splelchecker | Debug during Development |Write it for FireFox, ignore IE
Use the right DocType | Validate your markup | Validate your CSS | Why validating is good | Why tables are bad
Excavator is offline   Reply With Quote
Old 05-22-2010, 05:01 PM   PM User | #3
johnmerlino
Regular Coder

 
Join Date: Oct 2009
Posts: 189
Thanks: 38
Thanked 3 Times in 3 Posts
johnmerlino is an unknown quantity at this point
The container div is set to position relative so it acts as a reference point to the contained absolutely positioned divs. Is it possible to have it act as a reference point yet also allow it to overflow to enclose its containing absolutely positioned divs as well? If not, is there a workaround, aside from having to give the container a height property? thanks.
johnmerlino is offline   Reply With Quote
Old 05-22-2010, 05:03 PM   PM User | #4
Excavator
Master Coder


 
Excavator's Avatar
 
Join Date: Dec 2006
Location: Alaska
Posts: 9,410
Thanks: 22
Thanked 1,765 Times in 1,749 Posts
Excavator has a spectacular aura aboutExcavator has a spectacular aura aboutExcavator has a spectacular aura about
Quote:
Originally Posted by johnmerlino View Post
Is it possible to have it act as a reference point yet also allow it to overflow to enclose its containing absolutely positioned divs as well?
No. Not without a height.

Quote:
If not, is there a workaround? thanks.
Don't use ap. Position those elements with floats and margins instead.
__________________
Validate often DURING development - Use it like a splelchecker | Debug during Development |Write it for FireFox, ignore IE
Use the right DocType | Validate your markup | Validate your CSS | Why validating is good | Why tables are bad
Excavator is offline   Reply With Quote
Users who have thanked Excavator for this post:
johnmerlino (05-22-2010)
Reply

Bookmarks

Tags
auto, collapsing, css, divs, overflow

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 05:43 AM.


Advertisement
Log in to turn off these ads.