Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
325 views
in Technique[技术] by (71.8m points)

无法清除浮动?

<div id='html'>html</div>
<div id='content'>
<textarea id="text"></textarea>
</div>

为何无法清除浮动?

div#html{
    border:1px solid black;
    height:80px;
    width:80px;
    float:left;
 }
div#html::after{
    content:'';
    clear:both;
    display:block;        
 }
#content{
    width:900px;
    height:100px;
    border:2px solid red;
}
textarea{
    border:2px solid green;
    width:80%;
    height:80%;
}

显示成这样了

image.png

这是典型的清除浮动的方法

content:'';
clear:both;
display:block;

问题在哪里?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
::after

是写在父级清除子元素的浮动

#content{
    clear:both;     
 }

image.png


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...