Note that there are some explanatory texts on larger screens.

plurals
  1. POAligning images like google image search does
    primarykey
    data
    text
    <p>Google shows its images like this: <img src="https://i.stack.imgur.com/q9PkG.png" alt="align1"></p> <p>But then when I try to do it, I get this:</p> <p><img src="https://i.stack.imgur.com/43C2G.png" alt="align"></p> <p>It seems this will need something more than just float:left, but what? The images will be of unknown height and width. But I put in a max-height and max-width check so it doesn't get too crazy.</p> <p>Note: rowtable is just an array that holds the picture name (id). I cut some stuff out to clean the code.</p> <pre><code>function imageResize($image) { $maxWidth = 500; $maxHeight = 395; $size = getimagesize($image); if ($size) { $imageWidth = $size[0]; $imageHeight = $size[1]; $wRatio = $imageWidth / $maxWidth; $hRatio = $imageHeight / $maxHeight; $maxRatio = max($wRatio, $hRatio); if ($maxRatio &gt; 1) { $outputWidth = $imageWidth / $maxRatio; $outputHeight = $imageHeight / $maxRatio; } else { $outputWidth = $imageWidth; $outputHeight = $imageHeight; } //echo 'width="'.$outputWidth.'" height="'.$outputHeight.'"'; return 'width="'.$outputWidth.'" height="'.$outputHeight.'"'; } } $image = "images/screenshots/$rowtable[id].png"; ?&gt; &lt;div style="float:left; padding:5px;"&gt;&lt;img src="&lt;?php echo "images/screenshots/$rowtable[id].png"; ?&gt;" &lt;?php echo imageResize($image); ?&gt;&gt;&lt;/div&gt; </code></pre> <p>UPDATE:</p> <p>After watcher's comment, it works. But how can I get this?</p> <p><img src="https://i.stack.imgur.com/zTgUD.png" alt="align3"></p> <p>So have a wide picture center vertically, rather than sticking to the top.</p>
    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.
 

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