我有可膨胀的菜单,其中由薄的左手栏弹出(开放男性和关闭菜单类型)DIV @ 100%剩余可变宽度
多数如果时间,它会占用周围50像素,除了当它打开时,当它的约250.
我希望我的#内容div是100%的余数。因此,当它打开菜单时,它的100%页面 - 50px然后是100%页面-250px。
贝娄是我的HTML,我需要做什么我的基本CSS?
注我已经把关节外线路,独立出来的2divs indside包装
<div class="wrapper">
。
。
<div class="content">
<p>CONTENT HERE</p>
</div>
。
</div>
图相救......
式菜单关闭
|---------------------------------------------------------------------|
| THIS IS THE #WRAPPER DIV @100% |
||----| |------------------------------------------------------------||
|| | | ||
|| | | ||
||THIS| | THIS IS THE #CONTENT DIV ||
||IS | | @100% ||
||THE | | ||
||SIDE| | ||
||-BAR| | ||
||DIV | | ||
||@ | | ||
||20px| | ||
|| | | ||
|| | | ||
|| | | ||
|| | | ||
||----| |------------------------------------------------------------||
| |
|---------------------------------------------------------------------|
菜单中打开
|---------------------------------------------------------------------|
| THIS IS THE #WRAPPER DIV @100% |
||--------------| |--------------------------------------------------||
|| | | ||
|| | | ||
||THIS | | THIS IS THE #CONTENT DIV ||
||IS | | @100% ||
||THE | | ||
||SIDE | | ||
||-BAR | | ||
||DIV | | ||
||@ | | ||
||250 | | ||
||px | | ||
|| | | ||
|| | | ||
|| | | ||
||--------------| |--------------------------------------------------||
| |
|---------------------------------------------------------------------|
这是代码我一直在测试
function menushow()
{
screen_width = $(window).width() ; // returns width of browser viewport
//alert($(document).width()); // returns width of HTML document
//calculate content div width
cont_div_width = screen_width - 250;
(“#content”)。css(“width”,cont_div_width +“px”);
}
function menuhide()
{
screen_width = $(window).width() ; // returns width of browser viewport
//alert($(document).width()); // returns width of HTML document
//calculate content div width
cont_div_width = screen_width - 50;
(“#content”)。css(“width”,cont_div_width +“px”); }
其中
<a href="#" onclick="menuhide"><div id="logo" class="logo"></div></a>
和
<a href="#" onclick="menushow"><div id="logo" class="logo"></div></a>
和
<div id="content" class="content">
并添加onclick事件来调用javascripts? – 2013-02-21 11:08:20
等我想我明白了...我需要删除我的#content css宽度吗?或保持在100%? – 2013-02-21 11:10:12
我也使用onclicks来调用该事件吗? – 2013-02-21 11:16:03