Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

CSS Forum


You are currently viewing our CSS Forum as a guest. Please register to participate.
Login



Reply
Old 01-21-2010, 03:14 AM overflow auto
Ultra Talker

Posts: 254
Trades: 0
normally when i have a container div which for example has 2 inner divs floating left i usually float the container set it with a width and set height as auto so that as the height of any of the 2 inner divs increases the container div automatically increases

for the 2 inner divs i write
#outerdiv .innerdiv1{
float: left;
width: 400px;
height: auto;
}
#outerdiv .innerdiv2{
float: left;
width: 500px;
height: auto;
}

however i have seen a code for such a situation wherein the container is mentioned as
#containerdiv{
overflow: auto;
}


here the containerdiv is not set to float left and no width and height specified and only a single line as overflow: auto

my question instead of setting a float left, width of some value and height to auto for the containerdiv what is the need to use #containerdiv{ overflow: auto;} what advantage would it give if i were to have instead as #container{float: left; width: 900px; height: auto;} which i usually do

please advice

thanks
sudhakararaog is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 01-21-2010, 10:54 AM Re: overflow auto
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,371
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
The overflow: auto; is to trigger the "hasLayout" for IE so the container will not allow the floated elements to "escape".

http://www.quirksmode.org/css/clearing.html
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 01-21-2010, 11:27 AM Re: overflow auto
angele803's Avatar
Perfectly Imperfect

Posts: 1,772
Name: Stephanie
Location: Oklahoma
Trades: 2
Here's an example of why using overflow: auto; might work better. If you do this: #container{float: left; width: 900px; height: auto;}
but you wanted the container div to be centered, it would be a little difficult to achieve because you are floating the container to one side. If you use overflow: auto; instead of floating the container, you can apply auto margins on the container to center it - like this: #container{overflow: auto; width:900px; margin: 0 auto;}

Another advantage would be that when you use overflow: auto; instead of floating the container, you aren't removing the container from the natural flow of the document. Floating the container could cause you to get some weird results with surrounding content. If you can avoid floating the container, you know other elements outside of the container should behave normally.
__________________

Please login or register to view this content. Registration is FREE
angele803 is offline
Reply With Quote
View Public Profile
 
Old 01-21-2010, 11:50 AM Re: overflow auto
LadynRed's Avatar
Defies a Status

Posts: 10,017
Location: Tennessee
Trades: 0
Quote:
set height as auto so that as the height of any of the 2 inner divs increases the container div automatically increases
Setting height to auto is rather pointless, as the correct default behavior is for the container to stretch vertically with it's contents anyway.
__________________
Web Goddess & Web Standards Evangelist :) - Tables Be Gone !!

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE

LadynRed is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to overflow auto
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 1.39623 seconds with 12 queries