Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Regular Coder
    Join Date
    Apr 2007
    Posts
    144
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Div Inline Positioning

    In the code below you see i have a container div. Inside of that are two divs. I would like the two divs to align side-by-side and valign to the top of the container div.

    I can get them side-by-side, but not to valign both to top. What am i doing wrong?

    Code:
    <div class="" style="width:530px; border-width:1px; border-style:solid; border-color:#ccbbaa; text-align:left; padding:10px;">
    
    	<div class="" style="position:relative; z-index:7; width:300px;">
    
    		Epsum factorial non deposit quid pro quo hic escorol. Olypian quarrels et gorilla congolium sic ad nauseum. Souvlaki ignitus carborundum e pluribus unum. Defacto lingo est igpay atinlay. Marquee selectus non provisio incongruous feline nolo contendre. Gratuitous octopus niacin, sodium glutimate. Quote meon an estimate et non interruptus stadium. Sic tempus fugit esperanto hiccup estrogen. Glorious baklava ex librus hup hey ad infinitum. Non sequitur condominium facile et geranium incognito. Epsum factorial non deposit quid pro quo hic escorol. Marquee selectus non provisio incongruous feline nolo contendre Olypian quarrels et gorilla congolium sic ad nauseum. Souvlaki ignitus carborundum e pluribus unum.
    
    	</div>
    
    	<div class="" style="position:relative; z-index:6; width:200px; left:320px;"><IMG src='test.jpg' width='125'></div>
    
    </div>

  • #2
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    You are going about this the wrong way. You shouldn't be using position:relative; that way. You should be using floats instead. When you float something you also need to clear the float. This is what .clearfix does. Read more about that here: http://positioniseverything.net/easyclearing.html

    This is how I would do it
    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>Untitled Document</title>
    <style type="text/css">
    #container {
    width:530px;
    margin:auto;
    border:1px solid #CBA;
    padding:10px;
    }
    #col-1 {
    width:300px;
    float:left;
    }
    #col-2 {
    width:200px;
    float:left;
    }
    .clearfix:after {
    content: ".";
    display: block;
    height: 0;
    clear: both;
    visibility: hidden;
    }
    /* Hides from IE-mac \*/
    * html .clearfix {
    height: 1%;
    }
    /* End hide from IE-mac */
    </style>
    </head>
    <body>
    <div id="container" class="clearfix">
    	<div id="col-1"> Epsum factorial non deposit quid pro quo hic escorol. Olypian quarrels et gorilla congolium sic ad nauseum. Souvlaki ignitus carborundum e pluribus unum. Defacto lingo est igpay atinlay. Marquee selectus non provisio incongruous feline nolo contendre. Gratuitous octopus niacin, sodium glutimate. Quote meon an estimate et non interruptus stadium. Sic tempus fugit esperanto hiccup estrogen. Glorious baklava ex librus hup hey ad infinitum. Non sequitur condominium facile et geranium incognito. Epsum factorial non deposit quid pro quo hic escorol. Marquee selectus non provisio incongruous feline nolo contendre Olypian quarrels et gorilla congolium sic ad nauseum. Souvlaki ignitus carborundum e pluribus unum. </div>
    	<div id="col-2"><IMG src='test.jpg' width='125'></div>
    </div>
    </body>
    </html>
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #3
    Regular Coder
    Join Date
    Apr 2007
    Posts
    144
    Thanks
    5
    Thanked 0 Times in 0 Posts
    This solution for this problem can be found using either of the suggestions found here,

    http://www.webmaster-talk.com/css-fo...tml#post470469
    http://www.dhtmlgoodies.com/forum/vi...hp?p=9986#9986

  • #4
    The fat guy next door VIPStephan's Avatar
    Join Date
    Jan 2006
    Location
    Halle (Saale), Germany
    Posts
    8,695
    Thanks
    6
    Thanked 1,011 Times in 984 Posts
    Thanks for wasting our and other people’s time. Don’t ever cross-post again!

  • #5
    Regular Coder
    Join Date
    Sep 2007
    Location
    Raleigh, NC
    Posts
    273
    Thanks
    7
    Thanked 59 Times in 52 Posts
    The solution posted in dhtml goodies (display: table) won't work because IE does not support display: table.

    The solution at webmaster talk is essentially what Aero told you to do.

    I'm with Stephan. Don't waste our time with cross-posting.


  •  

    Posting Permissions

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