dcsimg
www.webdeveloper.com
Results 1 to 4 of 4

Thread: DIVS not floating

Hybrid View

  1. #1
    Join Date
    Sep 2009
    Posts
    51

    DIVS not floating

    Hi,

    I have two divs one after the other:

    HTML Code:
    <div id="myDiv" style="float: left; width: 500px;">
    
    </div>
    
    <div id="myDiv2" style="width: 500px;">
    
    </div>
    my goal here was to have the first one on the top left of the page, and the second one immediately to the right of it, but the second one is still below the first one.

    Could you please point out what I am doing wrong?

    Thanks.

  2. #2
    Join Date
    Mar 2006
    Posts
    172
    float the first one to left, and give the second one a margin that equals the width of the first.

    edit: maybe a hair bigger than the first one. Just depends on what you want to do.

    A left margin that equals the width of the first div.

    Sigh, nite nite time.
    Last edited by CFHutton; 11-25-2009 at 09:06 PM.

  3. #3
    Join Date
    Nov 2009
    Posts
    6
    you need to float both if you want them side by side...

    <div id="myDiv" style="float: left; width: 500px;">

    </div>

    <div id="myDiv2" style="float: left; width: 500px;">

    </div>


    you can put a <div style="clear:both; height:0; overflow:hidden;"></div> after it if you need those cleared, or clear it if needed on the div after that

  4. #4
    Join Date
    Mar 2006
    Posts
    172
    You're right, and thanks for the quick reply.

    I posted twice beyond the time last night. The last one was me remembering the way to get three columns with css.

    Again, thanks for covering for my mistake.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles