Skip to content

Commit f91b027

Browse files
committed
added float example
1 parent 5cd603f commit f91b027

File tree

1 file changed

+30
-9
lines changed

1 file changed

+30
-9
lines changed

css.html

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,19 @@
3232
.skipListItem{
3333
list-style-type: none;
3434
}
35+
/*style for demo*/
36+
.floatContainer{
37+
width: 200px;
38+
height: 100px;
39+
border: 2px solid purple;
40+
}
41+
.box{
42+
float: left;
43+
width:50px;
44+
height: 30px;
45+
border: 2px solid gray;
46+
margin:5px;
47+
}
3548
</style>
3649

3750
<!-- Just for debugging purposes. Don't actually copy this line! -->
@@ -85,20 +98,28 @@ <h2>1. float</h2>
8598
<p><strong>Question:</strong> How float works?</p>
8699
<p><strong>Answer:</strong> float is to push element on a side of a page with text wrap around it. you can create entire page or litter area by using float. if size of a floated element changes, text around it will reflow to accomodate the changes. You can have float left, right, none or inherit.</p>
87100
<p> if you set, 'float: left;' for an image, it will move to the left until the margin, padding or border of another block-level element is reached. The normal flow will wrap around on the right side.</p>
88-
101+
<pre><code>
102+
&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;
103+
&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;
104+
</code></pre>
105+
<div class="floatContainer">
106+
<div class="box"><span>1</span></div>
107+
<div class="box"><span>2</span></div>
108+
<div class="box"><span>3</span></div>
109+
<div class="box"><span>4</span></div>
110+
<div class="box"><span>5</span></div>
111+
</div>
89112
<p>If interviewer wants to ask one question about css, that would be most likely about float</a>.</p>
90113
<p><strong>extra:</strong> read the positioning constraints in <a href="http://www.w3.org/TR/CSS1/#floating-elements">W3.org: floating elements</a>.</p>
91114
ref: <a href="http://css-tricks.com/all-about-floats/">css-tricks: float</a>, <a href="http://alistapart.com/article/css-floats-101">float 101</a>
92115
</div>
93-
<!-- <div id="data_attribute">
94-
<h2>2. data-*</h2>
95-
<p><strong>Question:</strong> what is the use of data- attribute?</p>
96-
<p><strong>Answer:</strong> allow you to store extra information/data in the DOM. u can write valid html withe embeded private data. You can easily access data attribute by using javascript and hence a lot of libraries like knockout uses it.</p>
97-
<pre><code>
98-
&lt;div id=&quot;myDiv&quot; data-user=&quot;jsDude&quot; data-list-size=&quot;5&quot; data-maxage=&quot;180&quot;&gt;&lt;/div&gt;
99-
</code></pre>
116+
<div id="data_attribute">
117+
<h2>2. clear</h2>
118+
<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+
100121
<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>
101-
</div> -->
122+
</div>
102123
<!-- <div id="keygen">
103124
<h2>3. keygen</h2>
104125
<p><strong>Question:</strong> How can u generate public key in html?</p>

0 commit comments

Comments
 (0)