+ Reply to Thread
Results 1 to 6 of 6

Thread: CSS Float Problem 2

  1. #1
    gaptrast's Avatar
    gaptrast is offline x10 Sophmore gaptrast is an unknown quantity at this point
    Join Date
    Nov 2009
    Posts
    117

    CSS Float Problem 2

    Hello,

    I am using a website like this:

    CSS Float Problem 2-float.jpg

    Two floated divs with different heights according to the content.

    The problem is, that if I do not set a height it will show up like that they were not there.

    CSS Float Problem 2-float2.jpg

    Did you understand it? Is there a solution to solve it?
    Last edited by gaptrast; 05-11-2011 at 12:16 PM.
    LOOK RIGHT
    LOOK DOWN
    Questions you never knew you wanted answered - http://Wonderabout.info
    [New site!] Collection of fun computer pranks! - http://thefakevirus.com

  2. #2
    descalzo's Avatar
    descalzo is offline Grim Squeaker descalzo has a brilliant futuredescalzo has a brilliant futuredescalzo has a brilliant future
    Join Date
    Jul 2009
    Location
    Ankh-Morpork
    Posts
    7,636

    Re: CSS Float Problem 2

    Set up two pages, float01.html and float02.html and post links.
    Nothing is always absolutely so.

  3. #3
    misson is offline x10 Spammer misson is a jewel in the rough
    Join Date
    Mar 2008
    Location
    Libertatia
    Posts
    2,506

    Re: CSS Float Problem 2

    From the second figure, it looks like you want the floats to be auto-cleared. In addition to the sitepoint "Simple Clearing of Floats" article, read "Clearing Floats" on Quirksmode.

    Generally speaking, code says more than pictures. The best way of showing what you're doing when asking about wed design is to post minimal sample code and a/ link/s to a/ live page/s along with any figures.
    Be sure to read all pages linked in this post; they have further information that should prove useful. When asking for help, make sure you follow Eric Raymond's and Jon Skeet's guidelines for prompt, accurate responses. Please answer any questions I ask; they're not rhetorical (probably). Any posted code is intended as illustrative example, rather than a solution to your problem to be copied without alteration. Study it to learn how to write your own solution.
    Misson, not Mission.

  4. #4
    bidzey75's Avatar
    bidzey75 is offline x10Hosting Member bidzey75 is an unknown quantity at this point
    Join Date
    Apr 2011
    Posts
    51

    Re: CSS Float Problem 2

    Quote Originally Posted by gaptrast View Post
    Did you understand it? Is there a solution to solve it?
    I think... (emphasize on I THINK ) I understand, and a quick answer is no. someone can correct me if I'm wrong, but if you want an empty block you'll have to specify 3 things. Width, height, and display:block.

    Quote Originally Posted by gaptrast View Post
    Two floated divs with different heights according to the content.
    If by any chance you want your columns to be the same height there are few solutions to that, but if you want one that will stay away from javascript here's the code that take 3 columns and makes them all the same height of the longest. It's a dirty trick, but whoo whoo CSS is fun

    Actually what's happening here, is there's 3 containers and they are pushed off the screen to a percentage to show the one behind.
    more info here, credit:

    here's the code:
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head>
    <title>My title</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
    <style type="text/css">
    #container3 {
        float:left;
        width:100%;
        background:green;
        overflow:hidden;
        position:relative;
    }
    #container2 {
        float:left;
        width:100%;
        background:yellow;
        position:relative;
        right:30%;
    }
    #container1 {
        float:left;
        width:100%;
        background:red;
        position:relative;
        right:40%;
    }
    #col1 {
        float:left;
        width:26%;
        position:relative;
        left:72%;
        overflow:hidden;
    }
    #col2 {
        float:left;
        width:36%;
        position:relative;
        left:76%;
        overflow:hidden;
    }
    #col3 {
        float:left;
        width:26%;
        position:relative;
        left:80%;
        overflow:hidden;
    }
    	
    </style>
    </head>
    
    <body>
    <div id="container3">
        <div id="container2">
            <div id="container1">
                <div id="col1">
    			Column 1
    			<p>&nbsp;</p>
    			<p>&nbsp;</p>
    			<p>&nbsp;</p>
    			<p>&nbsp;</p>
    			<p>&nbsp;</p>
    			<p>&nbsp;</p>
    			<p>&nbsp;</p>
    			Bottom of Column 1
    			</div>
                <div id="col2">
    			Column 2
    			<p>&nbsp;</p>
    			<p>&nbsp;</p>
    			<p>&nbsp;</p>
    			Bottom of Column 2
    			</div>
                <div id="col3">
    			Column 3
    			<p>&nbsp;</p>
    			Bottom of Column 3
    			</div>
            </div>
        </div>
    </div>
    </body>
    </html>
    if you want 2 columns, take away a container and adjust the width accordingly
    Last edited by bidzey75; 05-11-2011 at 06:14 PM.

  5. #5
    playminigames is offline x10 Sophmore playminigames is an unknown quantity at this point
    Join Date
    Jul 2009
    Location
    earth
    Posts
    216

    Re: CSS Float Problem 2

    I also had this problem a couple of months ago, and it was really annoying. Im not sure if this is the correct solution, but I think I changed the div that contains everything(the one that you had to set the height, or it wouldn't work). For this changed I set a min-height, and also overflow:auto. This may or may not help you, but this is what has worked for me in the past.

  6. #6
    gaptrast's Avatar
    gaptrast is offline x10 Sophmore gaptrast is an unknown quantity at this point
    Join Date
    Nov 2009
    Posts
    117

    Cool Re: CSS Float Problem 2

    solved it using inline-block in parent element.

    thanks to http://becreativemagazine.com/2010/0...to-solve-them/
    LOOK RIGHT
    LOOK DOWN
    Questions you never knew you wanted answered - http://Wonderabout.info
    [New site!] Collection of fun computer pranks! - http://thefakevirus.com

+ Reply to Thread

Similar Threads

  1. CSS Float problem
    By gaptrast in forum Programming Help
    Replies: 9
    Last Post: 05-10-2011, 08:11 PM
  2. SlideDeck issue, CSS Float question, & google CSE questions...
    By vrufusx65v in forum Programming Help
    Replies: 10
    Last Post: 12-20-2010, 09:36 PM
  3. Div Float problem...
    By tdltinc in forum Graphics & Webdesign
    Replies: 6
    Last Post: 01-02-2009, 04:05 PM
  4. help with float:left; attribute
    By dellerdynamics in forum Programming Help
    Replies: 3
    Last Post: 12-12-2008, 02:03 PM
  5. Float CSS
    By jasgor9 in forum Programming Help
    Replies: 2
    Last Post: 04-07-2008, 01:47 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers