child div goes outside parent div

淺唱寂寞╮ 提交于 2021-01-27 06:29:07

问题


Currently I am designing a website using CSS and HTML etc. But I have faced a problem there : my child div goes outside the parent div when I add floating to the child. The site resides here my web design


回答1:


Be more specific. Where is the problem on the website?

Try to add this to css, so parent will know about the size of the child element:

#parent{
   overflow:hidden;
}



回答2:


You need to clear after your float.

Try adding this css:

CSS

.container:after {
    content: "";
    display: table;
    clear: both;
}



回答3:


Test the follwing CSS

.parentDiv {
    float: left,
    width: 200px,
    height: 30px

}

.childDiv{
    float: left,
    width: 100px,
}

The child division should be included in the parent one, you can use border on both element to make sure.



来源:https://stackoverflow.com/questions/13777013/child-div-goes-outside-parent-div

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!