html - Responsive elements - stretching and then stacking -
i'm new responsive web design, don't beat me badly.
i have fixed-width gallery page 1000px wide. 1000px outer div has 30px padding , 30px between each pair of images. i've got 910px of space available each pair. page might this:
(30px spacing)(500px img)(30px spacing)(410px image)(30px spacing)
(30px spacing)(480px img)(30px spacing)(430px image)(30px spacing)
(30px spacing)(450px img)(30px spacing)(440px image)(30px spacing)
...etc.
i'd convert responsive page images scale down browser window shrinks , stack on top of each other once browser window drops below 640px.
the way know make 640px change inside stylesheet. way can this? going have define styles within stylesheet every image?
for example, 480px wide image:
img.img480 { width: 48%; float: left; } @media screen , (max-width: 640px) { img.img480 { width: 100%; max-width: 480px; float: none; } }
here example of effect you're asking responsive design.
a couple things note:
- margins bad, use padding , wrappers instead
- floats bad, use inline-block instead
(demo)
html, body { margin: 0; } .wrapper { padding: 0 15px; font-size: 0; } .img-wrp { width: 50%; padding: 0 15px; display: inline-block; box-sizing: border-box; } .img-wrp img { width: 100%; } @media screen , (max-width: 640px) { .img-wrp { width: 100%; } } <div class="wrapper"> <i class="img-wrp"><img src="//lorempixel.com/640/480" /></i> <i class="img-wrp"><img src="//lorempixel.com/640/480" /></i> </div>
Comments
Post a Comment