I have a container that will have multiple images. I want to
1.), when there is only one image, the image takes up all the space:
------------------Container----------------
| --------------------------------------- |
| | | |
| | | |
| | Image | |
| | | |
| | | |
| --------------------------------------- |
-------------------------------------------
B) when there are two images
------------------Container----------------
| -------------------- ------------------ |
| | | | | |
| | | | | |
| | Image 1 | | Image 2 | |
| | | | | |
| | | | | |
| -------------------- ------------------ |
-------------------------------------------
C) If there are 3 or 4 images, stay on the same line
------------------Container----------------
| --------- --------- --------- --------- |
| | | | | | | | | |
| | | | | | | | | |
| | | | | | | | | |
| | | | | | | | | |
| | | | | | | | | |
| --------- --------- --------- --------- |
-------------------------------------------
D) When there are 5 images, the first line will have two lines, 4 images in the first line and 1 image in the second line.
------------------Container----------------
| --------- --------- --------- --------- |
| | | | | | | | | |
| | | | | | | | | |
| | | | | | | | | |
| | | | | | | | | |
| | | | | | | | | |
| --------- --------- --------- --------- |
| --------- |
| | | |
| | | |
| | | |
| | | |
| | | |
| --------- --------- --------- --------- |
-------------------------------------------
Is it possible to do this csswithout js?
And are there any libs that can do this?
source
share