Skip to content

Commit cc81ba6

Browse files
committed
toggle css example to save space
1 parent b7963b4 commit cc81ba6

File tree

1 file changed

+27
-16
lines changed

1 file changed

+27
-16
lines changed

css.html

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -106,17 +106,22 @@ <h2>1. float</h2>
106106
<p><strong>Question:</strong> How float works?</p>
107107
<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>
108108
<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>
109-
<pre><code>
109+
<div>
110+
<button id = "float" type="button" class="toggleExample btn btn-primary">show example</button>
111+
<div id="floatExample" class="hide">
112+
<pre><code>
110113
&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;
111114
&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;
112-
</code></pre>
113-
<div class="floatContainer demoContainer">
114-
<div class="box"><span>1</span></div>
115-
<div class="box"><span>2</span></div>
116-
<div class="box"><span>3</span></div>
117-
<div class="box"><span>4</span></div>
118-
<div class="box"><span>5</span></div>
119-
</div>
115+
</code></pre>
116+
<div class="floatContainer demoContainer">
117+
<div class="box"><span>1</span></div>
118+
<div class="box"><span>2</span></div>
119+
<div class="box"><span>3</span></div>
120+
<div class="box"><span>4</span></div>
121+
<div class="box"><span>5</span></div>
122+
</div>
123+
</div>
124+
</div>
120125
<p>If interviewer wants to ask one question about css, that would be most likely about float</a>.</p>
121126
<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>
122127
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>
@@ -125,18 +130,23 @@ <h2>1. float</h2>
125130
<h2>2. clear</h2>
126131
<p><strong>Question:</strong> When will you use clear?</p>
127132
<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>
133+
<div>
134+
<button id = "clear" type="button" class="toggleExample btn btn-primary">show example</button>
135+
<div id="clearExample" class="hide">
128136
<pre><code>
129137
&lt;style&gt;<br/> .clearLeft{<br/> clear:left;<br/> }<br/> &lt;/style&gt;
130138
&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;
131139
</code></pre>
132140
<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>
141+
<div class="clearContainer demoContainer">
142+
<div class="box"><span>1</span></div>
143+
<div class="box clearLeft"><span>2</span></div>
144+
<div class="box"><span>3</span></div>
145+
<div class="box"><span>4</span></div>
146+
<div class="box"><span>5</span></div>
147+
</div>
148+
</div>
149+
</div>
140150
<p>ref: <a href="http://www.w3.org/TR/CSS1/#clear">W3.org: clear</a>
141151
</div>
142152
<div id="keygen">
@@ -347,6 +357,7 @@ <h2>References</h2>
347357
<script src="js/jquery-2.0.3.min.js"></script>
348358
<script src="js/bootstrap.min.js"></script>
349359
<script src="js/highlight.pack.js"></script>
360+
<script src = "js/toggleExample.js"></script>
350361
<script>hljs.initHighlightingOnLoad();</script>
351362
<script type="text/javascript">
352363
(function() {

0 commit comments

Comments
 (0)