Note that there are some explanatory texts on larger screens.

plurals
  1. POCSS: Very simple image gallery
    primarykey
    data
    text
    <p>I don't always do web development, but when I do CSS is the most frustrating thing I can imagine. I'm trying to create a simple class to hold an image together with description. I want to have two rows, each with three images. Very simple. </p> <p>Here's my code for displaying images only, which works ok.</p> <pre><code>img { position: relative; margin: 0 auto; max-width: 650px; padding: 5px; margin: 10px 0 5px 0; border: 1px solid #ccc; } &lt;h3&gt;Screenshots&lt;/h3&gt; &lt;p&gt; &lt;a href="images/img1.png"&gt;&lt;img src="images/img1.png" width="200" height="140"&gt;&lt;/a&gt; &lt;a href="images/img2.png"&gt;&lt;img src="images/img2.png" width="200" height="140"&gt;&lt;/a&gt; &lt;a href="images/img3.png"&gt;&lt;img src="images/img3.png" width="200" height="140"&gt;&lt;/a&gt; &lt;a href="images/img4.png"&gt;&lt;img src="images/img4.png" width="200" height="140"&gt;&lt;/a&gt; &lt;a href="images/img5.png"&gt;&lt;img src="images/img5.png" width="200" height="140"&gt;&lt;/a&gt; &lt;a href="images/img6.png"&gt;&lt;img src="images/img6.png" width="200" height="140"&gt;&lt;/a&gt; &lt;/p&gt; &lt;h3&gt;Installation&lt;/h3&gt; </code></pre> <p>This shows images exactly as I want, three in each row and then there's a padding from &lt; p > and then <em>Installation</em> section. To get description under images in the same div I changed img in css to div.img and htm code to:</p> <pre><code>&lt;h3&gt;Screenshots&lt;/h3&gt; &lt;p&gt; &lt;div class="img"&gt; &lt;a target="_blank" href="images/img1.png"&gt;&lt;img src="images/img1.png" width="200" height="140"&gt;&lt;/a&gt; &lt;/div&gt; &lt;div class="img"&gt; &lt;a target="_blank" href="images/img1.png"&gt;&lt;img src="images/img1.png" width="200" height="140"&gt;&lt;/a&gt; &lt;/div&gt; &lt;div class="img"&gt; &lt;a target="_blank" href="images/img1.png"&gt;&lt;img src="images/img1.png" width="200" height="140"&gt;&lt;/a&gt; &lt;/div&gt; &lt;div class="img"&gt; &lt;a target="_blank" href="images/img1.png"&gt;&lt;img src="images/img1.png" width="200" height="140"&gt;&lt;/a&gt; &lt;/div&gt; &lt;div class="img"&gt; &lt;a target="_blank" href="images/img1.png"&gt;&lt;img src="images/img1.png" width="200" height="140"&gt;&lt;/a&gt; &lt;/div&gt; &lt;div class="img"&gt; &lt;a target="_blank" href="images/img1.png"&gt;&lt;img src="images/img1.png" width="200" height="140"&gt;&lt;/a&gt; &lt;/div&gt; &lt;/p&gt; &lt;h3&gt;Installation&lt;/h3&gt; </code></pre> <p>One would have thought that the resulting webpage is going to be exactly the same as img in the first case and div.img in the second have the same attributes. It is not the case though. With this code I get each div stretched to the full width of the column and images are one under the other at the left side of the div.</p> <p>I have also tried this code: <a href="http://www.w3schools.com/CSS/css_image_gallery.asp" rel="nofollow">http://www.w3schools.com/CSS/css_image_gallery.asp</a>, but in this case I get <em>Installation</em> and all the text that follows go onto the images, ignoring &lt; p > tag which has bottom margin.</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.
 

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