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

Categories

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

clear:both 放置的位置

css

.container{
    margin: 30px auto;
    width:600px;
    height: 300px;
 }
.p{
    border:solid 3px #a33;
 }
.c{
    width: 100px;
    height: 100px;
    background-color: #060;
    margin: 10px;
    float: left;
 }
 <div class="container">
      <div class="p">
           <div style="clear:both">//为什么不能写元素之前?
           <div class="c"></div>
           <div class="c"></div>
           <div class="c"></div>                                                                                                            
           <div style="clear:both">

       </div>
     </div>
     

带有clear属性的元素为什么不能写浮动元素之前?


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

1 Answer

0 votes
by (71.8m points)

带有clear属性的元素写在浮动元素之前,那它两侧本来就没有浮动元素,这个属性没有任何作用


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