tags:

views:

66

answers:

2

I have a container DIV position:relative. Hold everything in it Then one left column one right column, classical layout. Both of them are absolute positioned inside this relative #Main. I want the right to be fluid so I say top: 0px; left: 280px; (left column width) right: 0px all works but bottom:0px does not work. I say height: 100% still nothing. It snaps to the edges in all of them except the bottom. Height of that div is always 1px or 0px. Only px values seem to work but that would be unusable. What is the reason to that? any leads? thx in advance ...

code is pasted below

HTML:

<div id="Main">
    <div id="LeftSection">
            <div id="Logo">

            </div>
            <div id="dvPanelMenu">

            </div>
    </div>

    <div id="RightSection">
        <div id="dvTopMenu">

        </div>
        <div id="dvLogin">

        </div>
        <div id="dvContent">

        </div>
    </div>         

</div>

CSS:

body {
    margin: 0px;
}
#Main
{
    position: relative;
}
#LeftSection
{
    position: absolute;

    width: 280px;
    height: 100%;
}
    #Logo
    {
    position: absolute;
    margin: 10px 0px 10px 30px;
    }
    #dvPanelMenu
    {
        position: absolute;
        top: 140px;
        left: 0px;
        width: 280px;
        height: auto;
        text-align: left;
    }
#RightSection
{
    position: absolute;
    top: 0px;
    right: 0px;
    bottom: 0px;

    left: 280px;
    background-color: Blue;

}
#dvContent
{
    position: absolute;
    top: 36px;
    left: 2px;
    right: 0px;
    bottom: 20px;
    border: 1px dotted black;
}
    #dvTopMenu
    {
        position: absolute;
        top: 0.4em;
        left: 20px;
    }
    #dvLogin
    {
        position: absolute;
        right: 50px;
        top: 0.4em;
        font-family: Tahoma;
        font-size: 11px;
        text-align: left;
        color: Teal;
    }
A: 

I wouldn't necessarily recommend doing two column layout this way. Floats tend to work better in a cross-browser kind of way. That being said, the main thing you seem to be missing is height for your Main div. Put 100% height in and try that.

In all honesty I've tried absolute, relative and absolute+relative positioning but nearly always abandon it due to some issue on some browser or something just not being quite right.

For a float based approach, start with something like (works in Chrome 2, FF 3.5, IE8):

<html>
<head>
<title>2 columns</title>
<style type="text/css">
html, body, div { margin: 0; padding: 0; border: 0 none; }
#Main { height: 100%; padding-left: 280px; }
#LeftSection { margin-left: -280px; width: 280px; height: 100%; background: yellow; float: left; }
#Logo { margin: 10px 0px 10px 30px; }
#dvPanelMenu { text-align: left; }
#RightSection { width: 100%; background: blue; height: 100%; min-height: 100%; padding-top: 70px; }
#dvTopMenu { float: left; margin: -65px 0 0 20px; height: 40px; background: red; width: 300px }
#dvLogin { float: right; margin: -65px 50px 0 0; font-family: Tahoma; font-size: 11px; text-align: left; background: green; height: 50px; width: 200px; }
#dvContent { border: 1px dotted black; width: 100%; border: 1px dotted black; background: orange; }
</style>   
</head>
<body>
<div id="Main">
  <div id="LeftSection">
    <div id="Logo">Logo</div>
    <div id="dvPanelMenu">dvPanelMenu</div>
  </div>
  <div id="RightSection">
    <div id="dvTopMenu">dvTopMenu</div>
    <div id="dvLogin">dvLogin</div>
    <div id="dvContent">dvContent</div>
  </div>         
</div>
</body>
</html>
cletus
A: 

Modify your #Main and #RightSection selectors as follows:

#Main {
  margin: 0px;
  height: 100%; /* added */
}

#RightSection {
  position: absolute;
  top: 0px;
  right: 0px;
  height: 100%; /* bottom: 0; replace by this */

  left: 280px;
  background-color: Blue;
}

Also I suggest to read this http://www.webmasterworld.com/forum83/200.htm

Ivan Yatskevich
I tried floats but did not work. Should ı use positioning or not at all for doing it with floats?
When you use floats you shouldn't use absolute positioning. But for floats to render properly it is necessary to set their width explicitly. Here is an easy to grasp tutorial on css positioning - http://www.barelyfitz.com/screencast/html-training/css/positioning/
Ivan Yatskevich
Absolute positioning is perfectly acceptable if you are using fixed widths (non-fluid layout).
U62