开发者

CSS: float: right does not expand container

开发者 https://www.devze.com 2023-03-25 10:04 出处:网络
When I expand comm开发者_如何学Pythonent body that is floated to right my container does not expand with it. How can I fix this?

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

精彩评论

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