Note that there are some explanatory texts on larger screens.

plurals
  1. POCSS Responsive image technique mystery
    primarykey
    data
    text
    <p>I've been messing around with some responsive image techniques and came across one thing which confuses me. </p> <p>I have an image wrapped in a <code>href</code> tag inside a container. The container serves as a well, container to hold everything together. The <code>href</code> tag serves as the image container with a specific size defined. The image <code>width</code> is then set to 100% to fit its container.</p> <p>Here's the code:</p> <pre><code>The HTML: --------- &lt;div class="img-conatiner"&gt; &lt;a href="#" class="img-grid"&gt; &lt;img src="http://placekitten.com/300/300" alt="kittens!"&gt; &lt;/a&gt; &lt;a href="#" class="img-grid"&gt; &lt;img src="http://placekitten.com/300/300" alt="kittens!"&gt; &lt;/a&gt; &lt;a href="#" class="img-grid"&gt; &lt;img src="http://placekitten.com/300/300" alt="kittens!"&gt; &lt;/a&gt; &lt;a href="#" class="img-grid"&gt; &lt;img src="http://placekitten.com/300/300" alt="kittens!"&gt; &lt;/a&gt; &lt;a href="#" class="img-grid"&gt; &lt;img src="http://placekitten.com/300/300" alt="kittens!"&gt; &lt;/a&gt; &lt;a href="#" class="img-grid"&gt; &lt;img src="http://placekitten.com/300/300" alt="kittens!"&gt; &lt;/a&gt; &lt;/div&gt; The CSS ------- body { width: 90%; margin: 0 auto; background: tomato; } .img-grid { width: 20%; float: left; &lt;-- what is this for? padding: 10px; -webkit-box-sizing: border-box; } .img-grid img { width: 100%; } </code></pre> <p>Example: <a href="http://jsfiddle.net/TBVWG/2/" rel="nofollow">http://jsfiddle.net/TBVWG/2/</a></p> <p>Here's the thing, without the <code>float</code>, this technique doesn't work, the image blows up to its original size, ignoring the width of parent container. But how is the <code>float</code> keeping everything together?</p> <p>Thanks in advance.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload