css - Why clear: right doesn't work as intended -


i'm confused clear: left, clear: right , clear: both in css. know clear: both means doesn't allow floating elements on both sides of itself.

i did testing here. thought layout appear below, because b uses clear: both. doesn't. tell me why?

a
b
cd

updated (post code)

<div class="container">     <div class="a">a</div>     <div class="b">b</div>     <div class="c">c</div>     <div class="d">d</div>     <div class="cb"></div> </div>  .container{     width:100%;     border:1px solid red;     } .b{     float:left;     clear:both;     width:10%;     height:30px;     border:1px solid blue; } .a,.c,.d{     float:left;     width:10%;     height:30px;     border:1px solid blue; } .cb{     clear:both; } 

clear on element clears floats before in document order. doesn't clear floats after it. left , right values mean clearance of left floats , right floats preceding element respectively. don't mean clearing floats before , after element.

since c being floated, doesn't have clearance being applied, floats next b. b not try clear c because c comes after in document structure.

furthermore, clear: right doesn't have effect in test case because none of elements being floated right anyway.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -