html - Image grid with various sizes -
i'm building imagegrid containing of 7x3 blocks, 1 block need fill out 2x2. i'd use list since have responsive (the 2x2 should pop out below on mobile). , try avoid javascript. cant make work - ideas ?
big grid:
img img img img img img img img img img img blck.... img img img img img blck.... img mobile grid:
img img img img img img img img img img img img img img img img blck.............. blck..............
a friend @ office found nice solution
<html> <head> <style> .images { width: 100%; max-width: 1280px; position: relative; } img { width: 14.285714286%; height: auto; float: left; } .group { max-width: 42.857142857%; float: left; } .group img { width: 33.333333333%; } .teaser { width: 28.571428571%; background-color: blue; color: #fff; text-align: center; float: left; padding-bottom: 28.571428571%; position: relative; } .teaser div { position: absolute; width: 100%; height: 100%; top: 0; left: 0; background-color: blue; } @media (max-width: 480px) { img { width: 25%; } .group { max-width: 75%; } .group img { width: 33.333333333%; } .teaser { position: absolute; width: 100%; padding-bottom: 100%; float: none; margin-top: 100%; } } </style> </head> <body> <div class="images"> <div class="group"> <img src="http://placehold.it/400x400/ebe824/fff" alt="" /> <img src="http://placehold.it/400x400/cecaa4/fff" alt="" /> <img src="http://placehold.it/400x400/62c6a0/fff" alt="" /> <img src="http://placehold.it/400x400/f8f07e/fff" alt="" /> <img src="http://placehold.it/400x400/0f8b4b/fff" alt="" /> <img src="http://placehold.it/400x400/efb92b/fff" alt="" /> <img src="http://placehold.it/400x400/63d1d2/fff" alt="" /> <img src="http://placehold.it/400x400/f5c851/fff" alt="" /> <img src="http://placehold.it/400x400/42bfc0/fff" alt="" /> </div> <img src="http://placehold.it/400x400/c44d58/fff" alt="" /> <img src="http://placehold.it/400x400/ff6b6b/fff" alt="" /> <img src="http://placehold.it/400x400/c7f464/fff" alt="" /> <img src="http://placehold.it/400x400/4ecdc4/fff" alt="" /> <div class="teaser"> <div>follow me now</div> </div> <img src="http://placehold.it/400x400/556270/fff" alt="" /> <img src="http://placehold.it/400x400/542437/fff" alt="" /> <img src="http://placehold.it/400x400/53777a/fff" alt="" /> <img src="http://placehold.it/400x400/c02942/fff" alt="" /> </div> </body> </html>
Comments
Post a Comment