css - div设置float:left后高度设置自动会无效 ?
高洛峰
高洛峰 2017-04-17 11:20:58
0
4
578
.main_box_rightbox {
    width: 950px;
    height: auto;
    float: left;
    margin-left: 5px;
    margin-top: 3px;
    position: relative;
}

这样之后mainboxrightbox 高度只有16px
这是为什么??
有内容!!

高洛峰
高洛峰

拥有18年软件开发和IT教学经验。曾任多家上市公司技术总监、架构师、项目经理、高级软件工程师等职务。 网络人气名人讲师,...

reply all(4)
巴扎黑

Floats not cleared?

.clear{clear:both;}
左手右手慢动作

I can’t see all your code. I estimate the possible reasons:
1. The float is not cleared, causing the height to not be expanded.
2. The content is empty, causing the height to not be expanded. height:auto Automatically adjust the height based on the content within the block.

迷茫

Actually. You can set it in the parent p.
:
p {

overfloat: hidden;

}

That’s it. No need to use clear floats.

PHPzhong

Because you set position:relative, if the child element is positioned in absolute position, it will not be able to open the parent p

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template