O
O
otterely2014-11-29 20:31:31
css
otterely, 2014-11-29 20:31:31

How to implement a grid of images with different sizes in CSS?

Bottom line: there are a bunch of pictures of different sizes. It is necessary, using CSS3, to arrange them as shown in the picture:
18afb36cd0f04bf799ec412b8916434d.png
Now it looks like this:
5b5a694bc83e42debd6298ab5c61dcf6.png
Code:

<article id="preview">
<a href="link"><img src="img" class="img" alt="starry-night-over-the-rhone" height="1333" width="2000">Starry Night Over the Rhone</a>
</article>

(each block is 1 article)
CSS for them:
#preview {
    float: left;
    width: 30%;
    margin: 0px 1% 1%;
}

I understand that this is due to the fact that the last picture is adjusted to the block with the "Cypresses" picture:
594d4ab5568743e18128c94cc32cdb1d.png
But I don't know how to make it not do this.
Need a CSS solution (without px, in %)
Thanks in advance!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
_
_ _, 2014-11-29
@otterely

The simplest solution is to split it into N columns, since your images have the same width.

O
otterely, 2014-11-29
@otterely

Everything, the problem is solved, thank you very much ;)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question