css - How to do responsive rows of images in HTML? -
we want grid of images each row number of images same height potentially different widths. , whole thing needs grow , shrink browser width changes.
the best solution have come far is:
<div id="root"> <div><img src="img/r1a.jpg" style="max-width:33.334%; min-width:33.333%;"/><img src="img/r1b.jpg" style="max-width:33.334%; min-width:33.333%;"/><img src="img/r1c.jpg" style="max-width:33.334%; min-width:33.333%;"/></div> <div><img src="img/r2a.jpg" width="50%"/><img src="img/r2b.jpg" width="50%"/></div> <div><img src="img/r3a.jpg" style="max-width:33.334%; min-width:33.333%;"/><img src="img/r3b.jpg" style="max-width:33.334%; min-width:33.333%;"/><img src="img/r3c.jpg" style="max-width:33.334%; min-width:33.333%;"/></div> <div><img src="img/r4a.jpg" width="100%"/></div> <div><img src="img/r5a.jpg" style="max-width:43.733%; min-width:43.732%;"/><img src="img/r5b.jpg" style="max-width:25.584%; min-width:25.583%;"/><img src="img/r5c.jpeg" style="max-width:30.686%; min-width:30.685%;"/></div> <div><img src="img/r6a.jpg" style="max-width:33.861%; min-width:33.860%;"/><img src="img/r6b.jpg" style="max-width:16.480%; min-width:16.479%;"/><img src="img/r6c.jpg" style="max-width:33.184%; min-width:33.183%;"/><img src="img/r6d.jpg" style="max-width:16.480%; min-width:16.479%;"/></div> <div>
and css:
#root { max-width:1480px; margin:0 auto; } #root div { white-space:nowrap; } #root div img { padding:0; margin:0; padding-right:4px; -webkit-box-sizing:border-box; -moz-box-sizing:border-box; box-sizing:border-box; }
the main issue if images in same row have different widths, heights not same , looks bad because the padding uneven. works fine if images exact same size or if set padding-right in css 0.
another problem have compute percentage each image bit time consuming.
and problem there 4 pixel padding/margin on bottom of images cannot rid of.
what best way this? there slight modification can make fix of these issues or should use different structure?
here's screen shot of above code produces:
you can see how heights of images in second row not same.
#root div{position:relative; overflow:hidden;} #root div img{ height:100%}
you can use css image height.
Comments
Post a Comment