Skip to content

Commit 3ae35bf

Browse files
committed
added example for clear
1 parent f91b027 commit 3ae35bf

File tree

1 file changed

+25
-6
lines changed

1 file changed

+25
-6
lines changed

css.html

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,19 @@
3333
list-style-type: none;
3434
}
3535
/*style for demo*/
36-
.floatContainer{
36+
.demoContainer{
3737
width: 200px;
38-
height: 100px;
3938
border: 2px solid purple;
39+
}
40+
.floatContainer{
41+
height: 100px;
4042
}
43+
.clearContainer{
44+
height: 150px;
45+
}
46+
.clearLeft{
47+
clear:left;
48+
}
4149
.box{
4250
float: left;
4351
width:50px;
@@ -102,7 +110,7 @@ <h2>1. float</h2>
102110
&lt;style&gt;<br/> .floatContainer{<br/> width: 200px;<br/> height: 100px;<br/> border: 2px solid purple;<br/> }<br/> .box{<br/> float: left;<br/> width:50px;<br/> height: 30px;<br/> border: 2px solid gray;<br/> margin:5px;<br/> }<br/> &lt;/style&gt;
103111
&lt;div class=&quot;container&quot;&gt;<br/> &lt;div class=&quot;box&quot;&gt;&lt;span&gt;1&lt;/span&gt;&lt;/div&gt;<br/> &lt;div class=&quot;box&quot;&gt;&lt;span&gt;2&lt;/span&gt;&lt;/div&gt;<br/> &lt;div class=&quot;box&quot;&gt;&lt;span&gt;3&lt;/span&gt;&lt;/div&gt;<br/> &lt;div class=&quot;box&quot;&gt;&lt;span&gt;4&lt;/span&gt;&lt;/div&gt;<br/> &lt;div class=&quot;box&quot;&gt;&lt;span&gt;5&lt;/span&gt;&lt;/div&gt;<br/> &lt;/div&gt;
104112
</code></pre>
105-
<div class="floatContainer">
113+
<div class="floatContainer demoContainer">
106114
<div class="box"><span>1</span></div>
107115
<div class="box"><span>2</span></div>
108116
<div class="box"><span>3</span></div>
@@ -116,9 +124,20 @@ <h2>1. float</h2>
116124
<div id="data_attribute">
117125
<h2>2. clear</h2>
118126
<p><strong>Question:</strong> When will you use clear?</p>
119-
<p><strong>Answer:</strong> clear is used to stop wrap of an element around a floating element. .</p>
120-
121-
<p>ref: <a href="https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Using_data_attributes">MDN: data-*</a>, <a href="http://www.sitepoint.com/use-html5-data-attributes/">use data attribute</a></p>
127+
<p><strong>Answer:</strong> floating elements will not be accepted on the side you cleared. With 'clear' set to 'left', an element will be moved below any floating element on the left side. clear is used to stop wrap of an element around a floating element. .</p>
128+
<pre><code>
129+
&lt;style&gt;<br/> .clearLeft{<br/> clear:left;<br/> }<br/> &lt;/style&gt;
130+
&lt;div class=&quot;container&quot;&gt;<br/> &lt;div class=&quot;box&quot;&gt;&lt;span&gt;1&lt;/span&gt;&lt;/div&gt;<br/> &lt;div class=&quot;box clearLeft&quot;&gt;&lt;span&gt;2&lt;/span&gt;&lt;/div&gt;<br/> &lt;div class=&quot;box&quot;&gt;&lt;span&gt;3&lt;/span&gt;&lt;/div&gt;<br/> &lt;div class=&quot;box&quot;&gt;&lt;span&gt;4&lt;/span&gt;&lt;/div&gt;<br/> &lt;div class=&quot;box&quot;&gt;&lt;span&gt;5&lt;/span&gt;&lt;/div&gt;<br/> &lt;/div&gt;
131+
</code></pre>
132+
<p>as clear left is applied to the second box. nother would be on the left of that box and hence it is placed in a new row. </p>
133+
<div class="clearContainer demoContainer">
134+
<div class="box"><span>1</span></div>
135+
<div class="box clearLeft"><span>2</span></div>
136+
<div class="box"><span>3</span></div>
137+
<div class="box"><span>4</span></div>
138+
<div class="box"><span>5</span></div>
139+
</div>
140+
<p>ref: <a href="http://www.w3.org/TR/CSS1/#clear">W3.org: clear</a>
122141
</div>
123142
<!-- <div id="keygen">
124143
<h2>3. keygen</h2>

0 commit comments

Comments
 (0)