html - Responsive Polaroid Image with Unknown Image Dimensions -
i'm trying create gallery polaroid style it. when client uploads images won't know size of images, i'm trying scale image fit box proportionally.
(when images uploaded, change width or height 760px via php final dimensions unknown)
i have pretty want it, need more responsive when gets down mobile size. rather scaling in width , height (like should) image goes off canvas. or other solutions appreciated.
see code: html
<figure> <img src="https://placeimg.com/760/428/any" class="img-fill"> <figcaption>caption one</figcaption> </figure> <figure> <img src="https://placeimg.com/428/760/any" class="img-fill"> <figcaption>caption two</figcaption> </figure> css:
figure{ display:inline-block; height:350px; max-width:400px; min-width:300px; width:100%; overflow:hidden; position:relative; border:10px solid white; border-bottom:none; -webkit-box-shadow: 0 4px 16px rgba(0,0,0,0.75); -moz-box-shadow: 0 4px 16px rgba(0,0,0,0.75); box-shadow: 0 4px 16px rgba(0,0,0,0.75); } figcaption{ position:absolute; bottom:0; background:white; max-width:400px; min-width:300px; width:100%; height:40px; line-height:40px; text-align:center; font-family:'permanent marker', cursive; font-size:18px; } .img-fill { min-height: 100%; min-width: 100%; display: block; position: relative; top: 50%; left: 50%; -webkit-transform: translate(-50%, -50%); transform: translate(-50%, -50%); } code pen:
see pen responsive polaroid images
hi there few possibilities:
1) use media query solve problem like
@media screen , (max-width: 480px) { figure { max-width: 200px; height: 300px; margin: 10px 20px } } 2) or use relative size units em or vw or vh or % set width , height of figure
Comments
Post a Comment