+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 15

Thread: Aligning 2 divs with the 1 div above

  1. #1
    Administrator richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich's Avatar
    Join Date
    Mar 2008
    Location
    Somewhere only we know...
    Posts
    3,207
    Blog Entries
    14
    Real Name
    Rich
    Rep Power
    14

    Aligning 2 divs with the 1 div above

    Could someone explain why this doesn't work?
    Code:
        <div id="default">
            <div id="left">
                <div id="head_content" class="blue658CB3_14">
                    Head Content</div>
                <div style="border-collapse:collapse;float:left;width:100%;margin:0px 0px 0px 0px;padding:0px 0px 0px 0px;">
                <div id="left_menu">
                <div id="left_menu_header"></div>
                        <ul>
                            <li class="blue336799_8" onmouseover="mouseoverout(this,'','#B1B3FF','#336799');" onmouseout="mouseoverout(this,'','#BBCCDC','#336799');" onclick="link('/customers/');">Customers</li>
                            <li class="blue336799_8">Tasks</li>
                        </ul>
                </div>
                <div id="main_content">
                    Main Content</div>
                </div>
            </div>
            <div id="right">
                Right feed
            </div>
        </div>
    
    Code:
    #head_content
    {
        float:none;
        width:100%;
        line-height:30px;
        vertical-align:middle;
        border:solid 1px #336799;
        padding:0px 0px 0px 3px;
        margin:0px 0px 0px 0px;
    }
    #left_menu
    {
        margin:0px 0px 0px 0px;
        padding:0px 0px 0px 0px;
        text-align:left;
        float:left;
        width:17%;
        display:block;
    }
    #left_menu_header
    {
        height:20px;
    }
    #main_content
    {
        display:block;
        float:right;
        width:83%;
        background-color:#FFFFFF;
        border:solid 1px #336799;
        padding:0px 0em 0px 0px;
        margin: 0px 0px 0px 0px;
    }
    #left_menu ul
    {
        width:100%;
        list-style:none;
        margin:0px 0px 0px 0px;
        padding:0px 0px 0px 0px;
    }
    #left_menu li
    {
        cursor:pointer;
        width:100%;
        line-height:15px;
        padding:2px 2px 2px 2px;
        margin:0px 0px 0px 0px;
        background-color:#BBCCDC;
        border-bottom:solid 1px #FFFFFF;
    }
    
    I've attached a screenshot. I want the Main Content box to right align with the edge of the Head Content box and the menu and Main Content to be side by side.

    Any ideas?
    Attached Images

  2. #2
    Wolfmaster Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy's Avatar
    Join Date
    Mar 2008
    Location
    Peoria, IL
    Posts
    2,386
    Blog Entries
    5
    Real Name
    Wolff
    Rep Power
    15

    What browser are you using? IE6 and older is very buggy in this area.

    [Edit]Ok, I brought it up in FireFox and it rendered the same way. I've found over and over that using percentages causes problems like this. If I get more time, I'll noodle over it, but could you use a fixed width for your left menu area?[/edit]
    Last edited by Wolffy; June 25th, 2009 at 02:45 PM.
    Wolffy
    .-- ----- ..-. ..-. -.--
    Opinions expressed are my own and do not necessity reflect those of any sane person. Any code provided is intended to be an example and is provided AS IS. Void where prohibited by law. Not valid in California. Your mileage may vary.

  3. #3
    Super Sarcasm Mistress mehere is a glorious beacon of light mehere is a glorious beacon of light mehere is a glorious beacon of light mehere is a glorious beacon of light mehere is a glorious beacon of light mehere's Avatar
    Join Date
    Mar 2008
    Location
    Wide Awake In Dreamland
    Posts
    830
    Rep Power
    8

    try adjusting the left_menu width and the main_content width so that they don't equal 100 ...
    Last edited by mehere; June 25th, 2009 at 02:48 PM.
    Quote of the Month:
    INSIGHT: When the going gets tough, the tough get going. The smart left a long time ago.

    Questions to Ponder:
    Are people more violently opposed to fur rather than leather because it's much easier to harass rich women than motorcycle gangs?

    iif([sarcasm]=true,iif([you have to ask]=true,"didn't work","ha ha ha"),"not sarcasm")
    copyright © 2008 sbenj69

    Sarchasm: The gulf between the author of sarcastic wit and the person who doesn't get it.

  4. #4
    Administrator richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich's Avatar
    Join Date
    Mar 2008
    Location
    Somewhere only we know...
    Posts
    3,207
    Blog Entries
    14
    Real Name
    Rich
    Rep Power
    14

    Quote Originally Posted by mehere View Post
    try adjusting the left_menu width and the main_content width so that they don't equal 100 ...
    Yep. That's how I had it, but then the Main Content box doesn't align to the right of the header content box.

    I presume the width and alignment are linked.

  5. #5
    Administrator richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich's Avatar
    Join Date
    Mar 2008
    Location
    Somewhere only we know...
    Posts
    3,207
    Blog Entries
    14
    Real Name
    Rich
    Rep Power
    14

    Quote Originally Posted by Wolffy View Post
    What browser are you using? IE6 and older is very buggy in this area.

    [Edit]Ok, I brought it up in FireFox and it rendered the same way. I've found over and over that using percentages causes problems like this. If I get more time, I'll noodle over it, but could you use a fixed width for your left menu area?[/edit]
    Yeah...It's the same in all browsers....Can't understand why this issue wouldn't have been fixed?????

    Surely it's obvious 2 divs with widths adding up to 100% should be the same width as a single div with a width of 100%...

  6. #6
    Wolfmaster Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy's Avatar
    Join Date
    Mar 2008
    Location
    Peoria, IL
    Posts
    2,386
    Blog Entries
    5
    Real Name
    Wolff
    Rep Power
    15

    Yeah, you would think. Probably doesn't work that way tho and it just takes X% of what ever the number of pixels is and rounds it. Dang thing is probably off by 1px.
    Wolffy
    .-- ----- ..-. ..-. -.--
    Opinions expressed are my own and do not necessity reflect those of any sane person. Any code provided is intended to be an example and is provided AS IS. Void where prohibited by law. Not valid in California. Your mileage may vary.

  7. #7
    Barn Frequenter BLaaaaaaaaaarche will become famous soon enough BLaaaaaaaaaarche will become famous soon enough BLaaaaaaaaaarche's Avatar
    Join Date
    Mar 2008
    Posts
    188
    Rep Power
    5

    It works just fine for me. Do you have the rest of the code/css so I can test? More than likely, you have a padding set, and that is throwing it off. You cannot set a padding on a defined width otherwise it will throw it off by a couple of pixels.
    "You'll never be as perfect as BLaaaaaaaaarche."

  8. #8
    Wolfmaster Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy's Avatar
    Join Date
    Mar 2008
    Location
    Peoria, IL
    Posts
    2,386
    Blog Entries
    5
    Real Name
    Wolff
    Rep Power
    15

    Hmm, what browser does it work in? Just curious. I "de-padded" the thing and it still rendered goofy
    Wolffy
    .-- ----- ..-. ..-. -.--
    Opinions expressed are my own and do not necessity reflect those of any sane person. Any code provided is intended to be an example and is provided AS IS. Void where prohibited by law. Not valid in California. Your mileage may vary.

  9. #9
    Barn Frequenter BLaaaaaaaaaarche will become famous soon enough BLaaaaaaaaaarche will become famous soon enough BLaaaaaaaaaarche's Avatar
    Join Date
    Mar 2008
    Posts
    188
    Rep Power
    5

    I am using IE 6:

    Code:
    <html>
    <head>
    <title>richyrich</title>
    <link href="layout.css" rel="stylesheet" type="text/css" />
    </head>
    
    <body>
    
        <div id="default">
            <div id="left">
                <div id="head_content" class="blue658CB3_14">
                    Head Content</div>
                <div style="border-collapse:collapse;float:left;width:100%;margin:0px 0px 0px 0px;padding:0px 0px 0px 0px;">
                <div id="left_menu">
                <div id="left_menu_header"></div>
                        <ul>
                            <li class="blue336799_8" onmouseover="mouseoverout(this,'','#B1B3FF','#336799');" onmouseout="mouseoverout(this,'','#BBCCDC','#336799');" onclick="link('/customers/');">Customers</li>
                            <li class="blue336799_8">Tasks</li>
                        </ul>
                </div>
                <div id="main_content">
                    Main Content</div>
                </div>
            </div>
            <div id="right">
                Right feed
            </div>
        </div>
    
    </body>
    </html>
    
    I just added the right and left div tag properties:

    Code:
    #head_content {
        float:none;
        width:100%;
        line-height:30px;
        vertical-align:middle;
        border:solid 1px #336799;
        padding:0px 0px 0px 3px;
        margin:0px 0px 0px 0px;
    }
    #left_menu {
        margin:0px 0px 0px 0px;
        padding:0px 0px 0px 0px;
        text-align:left;
        float:left;
        width:17%;
        display:block;
    }
    #left_menu_header {height:20px;}
    #main_content {
        display:block;
        float:right;
        width:83%;
        background-color:#FFFFFF;
        border:solid 1px #336799;
        padding:0px 0em 0px 0px;
        margin: 0px 0px 0px 0px;
    }
    #left_menu ul {
        width:100%;
        list-style:none;
        margin:0px 0px 0px 0px;
        padding:0px 0px 0px 0px;
    }
    #left_menu li {
        cursor:pointer;
        width:100%;
        line-height:15px;
        padding:2px 2px 2px 2px;
        margin:0px 0px 0px 0px;
        background-color:#BBCCDC;
        border-bottom:solid 1px #FFFFFF;
    }
    #left {
    	width:90%;
    	float: left;
    }
    #right {
    	width: 10%;
    	float: left;
    }
    
    "You'll never be as perfect as BLaaaaaaaaarche."

  10. #10
    Administrator richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich's Avatar
    Join Date
    Mar 2008
    Location
    Somewhere only we know...
    Posts
    3,207
    Blog Entries
    14
    Real Name
    Rich
    Rep Power
    14

    I have it rendering correctly in IE6. I did have some padding in the divs, so pushed the main content an extra couple of pixels and put a minus margin on the left menu to align it to the left.

    However, the Main Content box is not the full width in FF. See attached screenshots...The IE one is how I want it to look.

    Here is what I have now:-
    Code:
        <div id="default">
            <div id="left">
                <div id="head_content" class="blue658CB3_14">
                    Head Content</div>
                <div id="main_content">
                <div id="left_menu">
                <div id="left_menu_header"></div>
                        <ul>
                            <li class="blue336799_8" onmouseover="mouseoverout(this,'','#B1B3FF','#336799');" onmouseout="mouseoverout(this,'','#BBCCDC','#336799');" onclick="link('/customers/');">Customers</li>
                            <li class="blue336799_8">Tasks</li>
                        </ul>
                </div>
                    <div id="right_content">
                        <div style="width: 100%;">
                            Main Content
                        </div>
                    </div>
                </div>
            </div>
            <div id="right">
                Right feed
            </div>
        </div>
    
    CSS
    Code:
    #left
    {
        float: left;
        width: 77%;
        text-align: left;
    }
    #right
    {
        left:0px;
        vertical-align:top;
        text-align:left;
        width: 20%;
        float:right;
    }
    #head_content
    {
        float:none;
        width:100%;
        line-height:30px;
        vertical-align:middle;
        border:solid 1px #336799;
        border-collapse:collapse;
        padding:0px 0px 0px 3px;
        margin:0px 0px 0px 0px;
    }
    #main_content
    {
        float:none;
        width:100%;
        padding:0px 0px 0px 5px;
        margin:3px 0px 0px 0px;
        border:solid 0px #FFFFFF;
        text-align:right;
    }
    #left_menu
    {
        margin:0px 0px 0px -2px;
        padding:0px 0px 0px 0px;
        text-align:left;
        float:left;
        width:150px;
    }
    #left_menu_header
    {
        height:20px;
    }
    #right_content
    {
        text-align:left;
        float:right;
        background-color:#FFFFFF;
        border:solid 1px #336799;
        padding:2px 2px 2px 2px;
        margin: 0px 0px 0px 4px;
    }
    #left_menu ul
    {
        width:100%;
        list-style:none;
        margin:0px 0px 0px 0px;
        padding:0px 0px 0px 0px;
    }
    #left_menu li
    {
        cursor:pointer;
        width:100%;
        line-height:15px;
        padding:2px 2px 2px 2px;
        margin:0px 0px 0px 0px;
        background-color:#BBCCDC;
        border-bottom:solid 1px #FFFFFF;
    }
    #left_menu li:hover
    {
        background-color:#B1B3FF;
    }
    
    Attached Images

+ Reply to Thread
Page 1 of 2 1 2 LastLast

Tags for this Thread

Bookmarks

Posting Permissions

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

SEO by vBSEO