Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You could look at how Google does it in Firebug (or any equivalent tool). I just did, and apparently they wrap each image in a div (actually, a &lt;li&gt;) with height set to the height of the image and vertical padding set to make up the difference. For example, here's one of them from a search I just ran:</p> <pre><code>&lt;li class="rg_li" style="width: 140px; height: 89px; padding: 11px 0pt;"&gt; </code></pre> <p>(See <a href="https://stackoverflow.com/questions/7794077/aligning-images-like-google-image-search-does/7794142#7794142">watcher's answer</a> for the styles applied to the class <code>rg_li</code>.) Apparently, they also adjust the height of each line dynamically to match the height of the tallest image on it, so if I resize the window, the padding values get recomputed.</p> <p>But anyway, if you just want a bunch of images vertically centered, <strong>you don't need any of this trickery</strong>. Just wrap all the images together in a &lt;p&gt; or &lt;div&gt; and style them with <code>vertical-align: middle</code>.</p> <pre><code>&lt;p style="text-align: justify"&gt; &lt;img style="vertical-align: middle" src="..." /&gt; &lt;img style="vertical-align: middle" src="..." /&gt; ... &lt;/p&gt; </code></pre> <p>You can even do this without CSS if you want, by using the old HTML <code>align</code> attribute, like this:</p> <pre><code>&lt;p align="justify"&gt; &lt;img align="middle" src="..." /&gt; &lt;img align="middle" src="..." /&gt; ... &lt;/p&gt; </code></pre>
    singulars
    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. VO
      singulars
      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