Forum Moderators: not2easy
So far none of the mentioned fixes work for me. My personal problem is that my sidebar is using text for the buttons. Therefore it needs to be resizable. Also however, the box that it's contained in has a border. So this needs to be resized as well. I am trying to create a truly fluid layout. But I am afraid it may not be possible :(
Here's my code:
#menu { float: left; margin-left: 14px; padding: 7px; border: solid 2px #004590 }
#content { border: solid 2px gray; padding: 7px; margin: 0 14px 0 14px; float: left }
The margins and padding are just there for aesthetic reasons. The idea in itself is simple but I don't know if it can be done. Thanks for any help.
I personally am using pixels for fonts for various reasons though I will offer a text sizing widget. But I though, why not size the menu in ems so that it resizes based on the text? Then I have a width which I can use with the content as a margin. This works perfectly. Well almost, the only minor problem is that the margin between the sidebar and content gets a little big since it keeps getting multiplied when the size is increased but it doesn't bother me that much. But a workaround would be nice... ;)
Here's my end code:
#menu { float: left; margin-left: 14px; padding: 7px; width: 10.9em; border: solid 2px #004590 }
#content { border: solid 2px gray; padding: 7px; margin: 0 14px 0 14.6em }
HTH
I use fixed positioning for the menu divs in browsers that support it, giving the illusion of a column that is the length of the page. I don't use any tiling background images in this, though I suppose you could, they just wouldn't scroll with the rest of your page, like a frame. If you want your menu to scroll, then you don't have to mess with fixed positioning at all. In the browsers that don't support fixed positioning (IE and NS4), I get the height of the content div and set the menu div to that height. I had to add 15 pixels for some reason to get the menu div line up with the content div at the bottom. You may want to execute the menu resizing code on the window.onResize() event, if resizing changes the height of your content div. Wrapper divs sre also necessary to pull this off. Here's some example code:
//stylesheet code
#content {
position: absolute;
top: 1em;
padding-left: 11em;
background:
}
#contentwrapper{
position: absolute;
width: 100%;
right: 0em;
left: 0em;
top: 0em;
}
#menu{
position: fixed;
left: 0em;
top: 0em;
width: 10.5em;
height: 100%;
background: #44b;
}
#menuwrapper{
position: fixed;
left: 0em;
top: 0em;
height: 100%;
width: 10.5em;
}
//end of stylesheet code
------------------------------------------------------------
//html code
<div id="menuwrapper">
<div id="menu">
//menuing code goes here
</div>
</div>
<div id="contentwrapper">
<div id="content">
//loads of content goes here.
</div>
</div>
<script language="javascript" src="menuheight.js">
</script>
//end of html code
------------------------------------------------------------
//this code is in the menuheight.js file
//browsersniff for ie and ns4, only necessary if we're using
//fixed positioning for the menu
iens4 = (navigator.appName!= "Opera" && (document.all¦¦document.layers))? true:false;
//get height of content div
content_height = document.getElementById('content').offsetHeight + 15;
//change height of menu divs to that of content divs
if(iens4) document.write( '\<style\> #menuwrapper, #menu {position: absolute; height:' + content_height + 'px}\</style\>')
//end of javascript code
Postscript: I just tried using the window.onresize event handler to resize the menu div, with bad results (blank page) in ie6. So if you do this, and someone resizes their browser, you should reload the page on resize. This works:
<body onResize="window.location.href = window.location.href;">
If you have a form on the page, this is proably not the best solution as any form information that had been typed in prior to resizing will be lost, but that seems like a rare case.