-1

I have a fixed with container, lets say 1120px. Inside this container, i have a left sidebar which is 400px, and i need a right sidebar which is expanding from the container and touching the right side of the screen. Here is an image explaining the layout i want:

Explaining the issue

This is the progress i made so far: http://jsfiddle.net/UvxK8/

#wrapper {
    background:#f0f0f0;
    margin:0 auto;
    width:400px;
    overflow:hidden;
}

#wrapper .left {
    width:100px;
    float:left;
    height:600px;
    background:#333;
}

#wrapper .right {
    position:absolute;
    margin-left:100px;
    height: 650px;
    background: green;
    min-width:100%;
}

Obviously its not good, because the right sidebar is too wide and a horizontal scrollbar appears.

passatgt
  • 4,234
  • 4
  • 40
  • 54

2 Answers2

0

The image you've used doesn't match your desicription of what you want; I think maybe you're looking at this the wrong way. If the right sidebar spills beyond the container, what's the point of the fixed width container at all?

From your image, it looks like what you want is...

HTML

<div id="header"><h1>Content here.</h1></div>
<div id="container">
    <div id="container-left">
        <p>Content here.</p>
    </div>
    <div id="container-right">
        <p>Content here.</p>
    </div>
</div>

CSS

#header {width:1120px;}
#container {width:100%; min-width:100%;}
#container-left {width:400px; float:left; }
#container-right {width:100%; min-width:100%;}

This will create the image illustration you've used. jFiddle here: http://jsfiddle.net/4JNX2/

Sinister Beard
  • 3,570
  • 12
  • 59
  • 95
0

Add position relative to your wrapper. try this

HTML

<div id="wrapper">
<div id="left">
</div>
<div id="right">
</div>
</div>

CSS

#wrapper
{width:1120px;
background:#096;
margin:0 auto;
position:relative;
}

#wrapper #left {
width:10%;
float:left;
height:600px;
background:#333;
}

#wrapper #right {
position:absolute;
margin-left:10%;
height: 650px;
background: green;
min-width:95%;
}
Atal Shrivastava
  • 674
  • 1
  • 9
  • 35
  • A horizintal scrollbar still appears based on the browser width, so this is not a good solution. – passatgt Mar 17 '14 at 10:02
  • i have edited my answer check [fiddle](http://jsfiddle.net/Z2R7S/). this is for fixed 1120px container. if you are looking for responsive on this then you need to add media queries – Atal Shrivastava Mar 17 '14 at 11:21