Clear inside div A 正在清除 div A 外部的 div B 的浮动
这是我在尝试创建带有侧边栏的布局时多次遇到的问题。
我在这里举了一个例子: http://samutz.com/div.html
#content 里面有东西只需要在 #content 内浮动然后清除。但是当我尝试清除#content内部时,它也会清除#sidebar的浮动,尽管#sidebar位于#content之外。
This is a problem I've had several times when trying to create layouts with a sidebar.
I made an example here: http://samutz.com/div.html
#content has stuff inside it that needs to float and then clear within #content only. But when I try to clear inside #content, it clears the #sidebar's float as well, despite #sidebar being outside of #content.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
选项A:
overflow:hidden; Zoom:1;
如果这弄乱了 #content 文本,请将文本放入这个新的 div 中:
http:// /medero.org/clear2.html
溢出技术说明:http://work.arounds .org/clearing-floats/
选项 B:
您也可以绝对定位侧边栏,但如果它变长,您可能不得不弄乱最小高度。
额外:
如果您需要将侧边栏包含在主包装器中:
http://medero。 org/clear3.html
Option A:
overflow:hidden; zoom:1;
If this messes up #content text, put the text inside this new div:
http://medero.org/clear2.html
Explanation for overflow technique: http://work.arounds.org/clearing-floats/
Option B:
You can also absolutely position the sidebar but you might have to mess with min-heights if it becomes long.
Extra:
If you need to contain the sidebar with your main wrapper:
http://medero.org/clear3.html