开发者

CSS: float: right does not expand container

When I expand comm开发者_如何学Pythonent body that is floated to right my container does not expand with it. How can I fix this?

Better explanation: http://jsfiddle.net/5fmpp/


Add overflow: hidden to the container so it can contain the float:

.comment
{
    width: 960px;
    margin: auto;
    margin-top: 24px;
    font-size: 14px;
    background-color: #777777;
    overflow: hidden;
}


Check this out.

You need to clear the float at the end of the comment box


The modern way to solve this would be to add display: flow-root; to the container in order to establish a new block formatting context.

overflow: hidden also establishes a new block formatting context but with its obvious side effects.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜