使子div在页面宽度上延伸 [英] Make child div stretch across width of page
问题描述
假设我有以下HTML代码:
Suppose I have the following HTML code:
<div id="container" style="width: 960px">
<div id="help_panel" style="width: 100%; margin: 0 auto;">
Content goes here.
</div>
</div>
如果我想help_panel div在页面/ broswer的宽度上延伸,的页面/浏览器的宽度大于960px(这是为容器div设置的宽度),是否可以使用上面的结构呢?我想让帮助面板的div扩展超出容器div中设置的宽度限制,如果页面宽度大于960px。
If I want the help_panel div to stretch across the width of the page/broswer, even if the width of the page/browser is wider than 960px (which is the width set for the container div), is it possible to do it with the above structure? I want to get the help panel div to expand beyond the width limits set in the container div if the page is wider than 960px.
我很好奇,如果这可以用上述结构完成。还是我必须把help_panel div放在容器div之外,使其工作?
I am curious if this can be accomplished with the above structure. Or will I have to put the help_panel div outside of the container div to make it work?
谢谢!
推荐答案
您需要使用
position:absolute;
left:0;
right:0;
这篇关于使子div在页面宽度上延伸的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!