tags:

views:

58

answers:

2

Hi, I've got the following HTML code:

<body> 
<div id="Frame">

    <div id="Body">
        <div id="Panel">Side panel, fixed width.</div>
        <div id="Content">The rest of the content, should be dynamic width and fill up rest of space horizontally.</div>
    </div>

    <div id="Foot">
        <div>FooBar.</div>
    </div>

</div>
</body>

What I'm trying to do is make it so that #Panel is of a fixed width (~200 pixels) and on the left hand side, and that #Content is immediately to the right of #Panel but is of "dynamic" width and fills the rest of the space in the browser screen horizontally. I've tried a lot of different things but haven't been able to get it working -- the farthest I've gotten is to the point where #Panel is on the left and #Content is to the right of #Panel and fills of the rest of the space, but #Content starts below #Panel whereas I'd like it to start at the same vertical position.

I did find this, however I wasn't able to apply it to the HTML above.

If anyone could help it'd be appreciated.

A: 

Try this to get you started. Sizes can be adjusted from here, and there are other ways to approach it. I set background colors just so you can see what's happening.

<style type="text/css">
    #Panel {
        float: left;
        width: 200px;
        background-color: #fff0f0;
    }
    #Content {
        float: left;
        width: 65%;
        margin-left: 1em;
        background-color: #f0fff0;
    }
    #Foot {
        clear: both;
        background-color: #f0f0ff;
    }
</style>
Stephen P
+1  A: 

Here's that link, applied to your code:

CSS

#frame   { background:pink }
#panel   { background:orange; width:200px; float:left }
#content { background:khaki; margin-left:200px }
#foot    { background:cornflowerblue }

HTML

<div id='frame'>
  <div id='body'>

    <div id='panel'>
      Side panel, fixed width.
    </div>

    <div id='content'>
      The rest of the content, should be dynamic width and fill up rest of space 
      horizontally.
    </div>

  </div><!-- End #body -->

  <div id='foot'>
    <div>FooBar.</div>
  </div>

</div><!-- End #frame -->

Works pretty well! Although, IMHO, you don't need the frame or body (but I don't know the master plan). That would look like this:

<div id='panel'>
  Side panel, fixed width.
</div>

<div id='content'>
  The rest of the content, should be dynamic width and fill up rest of space 
  horizontally.
</div>

<div id='foot'>
  <div>FooBar.</div>
</div>
Steve
+1 this is the best approach IMO. Works well in IE6 too.
MiG