简体   繁体   English

CSS中的浮动div问题

[英]problem with floating divs in CSS

I am trying to put 2 columns into a website, I've got that to work fine but for whatever reason, the rest of the page doesn't change size to suit the content in the left column. 我正在尝试将2列放到网站上,我已经可以正常工作了,但是出于任何原因,页面的其余部分都不会更改大小以适合左侧列的内容。 Here is how it looks: www.kelownafoodspecials.com/indexsides.php. 外观如下:www.kelownafoodspecials.com/indexsides.php。

Pretty stuck so any advice would be greatly appreciated. 非常卡住,所以任何建议将不胜感激。 Thanks, 谢谢,

K ķ

您应该在#contentright之后直接添加<div style="clear:both;"></div>

you must float your #content div also. 您还必须浮动#content div。 For any elements decalres as float:left(or right) , if their containing elements are not also floated elements, the containing elements will not expand to fit the content and it will overlay it's containing element as you are seeing there. 对于任何元素如float:left(或right)贴花,如果它们的包含元素也不是浮动元素,则包含元素将不会扩展以适合内容,并且将覆盖其包含元素(如您所见)。

Try this (assuming none of your content is meant to overflow) 试试看(假设您的所有内容都不会溢出)

#content {
    overflow: hidden;
}

I just tried it using Firebug, and nothing appears to be chopped off (and the #content will expand to contain it's floated child). 我只是使用Firebug尝试了一下,似乎没有被砍掉(并且#content会扩展为包含它的浮动子对象)。

You could append a <div class="clear"/> whose style could like like: 您可以附加一个<div class="clear"/>其样式应为:

.clear {
  clear:both;
  display:block;
  float:none;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM