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
目前我正在使用CSS和HTML等设计一个网站。但是我遇到了一个问题:当我向孩子添加浮动时,我的孩子div超出了父div。该网站驻留在我的网页设计中
3 个解决方案
#1
14
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:
尝试将此添加到css,因此父级将知道子元素的大小:
#parent{
overflow:hidden;
}
#2
3
You need to clear after your float.
漂浮之后你需要清除。
Try adding this css:
尝试添加此css:
CSS
CSS
.container:after {
content: "";
display: table;
clear: both;
}
#3
-1
Test the follwing CSS
测试下面的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.
子分区应该包含在父分区中,你可以在两个元素上使用border来确定。
#1
14
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:
尝试将此添加到css,因此父级将知道子元素的大小:
#parent{
overflow:hidden;
}
#2
3
You need to clear after your float.
漂浮之后你需要清除。
Try adding this css:
尝试添加此css:
CSS
CSS
.container:after {
content: "";
display: table;
clear: both;
}
#3
-1
Test the follwing CSS
测试下面的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.
子分区应该包含在父分区中,你可以在两个元素上使用border来确定。