...

View Full Version : Div Inline Positioning



cesarcesar
10-04-2007, 06:55 PM
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?



<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>

_Aerospace_Eng_
10-04-2007, 07:02 PM
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

<!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>

cesarcesar
11-14-2007, 08:40 AM
This solution for this problem can be found using either of the suggestions found here,

http://www.webmaster-talk.com/css-forum/104721-div-inline-positioning.html#post470469
http://www.dhtmlgoodies.com/forum/viewtopic.php?p=9986#9986

VIPStephan
11-14-2007, 02:55 PM
Thanks for wasting our and other peopleís time. Donít ever cross-post again!

vtjustinb
11-14-2007, 04:04 PM
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.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum