html - How to put multiple images of variable widths into one row and make it responsive? -
i have 4 images showing in row shown below. images of variable widths. image list randomly generated can't predict widths. need put of them 1 single row. in smaller devices should in 1 row. how can this?
<div class="relatedphotos"> <a href="/photos/natural-wonders-of-world-26051931"> <div class="relatedphoto"> <img src="/store/photos/thpubs/thumb_26051931-img_05_l.jpg" alt="thumb 26051931 img 05 l"> <p>natural wonders of world</p> </div> </a> <a href="/photos/natural-wonders-of-world-35991100"> <div class="relatedphoto"> <img src="/store/photos/thpubs/thumb_35991100-wallhaven-65322.jpg" alt="thumb 35991100 wallhaven 65322"> <p>natural wonders of world</p> </div> </a> <a href="/photos/natural-wonders-of-world-84217069"> <div class="relatedphoto"> <img src="/store/photos/thpubs/thumb_84217069-20140929_170747.jpg" alt="thumb 84217069 20140929 170747"> <p>natural wonders of world</p> </div> </a> <a href="/photos/natural-wonders-of-world-18133515"> <div class="relatedphoto"> <img src="/store/photos/thpubs/thumb_18133515-wallhaven-141502.jpg" alt="thumb 18133515 wallhaven 141502"> <p>natural wonders of world</p> </div> </a> </div>
here's css :
.relatedphotos { width: 100%; white-space: nowrap; display: table; .relatedphoto { max-width: 100%; background-color: #ffffff; padding: 5px; border: 1px solid #dddddd; margin-left: 2px; margin-right: 2px; -webkit-box-shadow: 0 7px 5px -7px #adadad; -moz-box-shadow: 0 7px 5px -7px #adadad; box-shadow: 0 7px 5px -7px #adadad; vertical-align: middle; display: table-cell; float: left; p { margin-top: 5px; margin-bottom: 0px; text-align: center; color: #808080; font-size: 12px; } } }
since number of images known (4) can divide width of row 4.
*{ padding:0; margin:0; } .relatedphoto{ width:25%; float:left; } .relatedphoto img{ width:100%; }
<div class="relatedphotos"> <a href="/photos/natural-wonders-of-world-26051931"> <div class="relatedphoto"> <img src="http://i.imgur.com/t0vymzs.jpg" alt="thumb 26051931 img 05 l"> <p>natural wonders of world</p> </div> </a> <a href="/photos/natural-wonders-of-world-35991100"> <div class="relatedphoto"> <img src="http://i.imgur.com/t0vymzs.jpg" alt="thumb 35991100 wallhaven 65322"> <p>natural wonders of world</p> </div> </a> <a href="/photos/natural-wonders-of-world-84217069"> <div class="relatedphoto"> <img src="http://i.imgur.com/aikykp8.jpg" alt="thumb 84217069 20140929 170747"> <p>natural wonders of world</p> </div> </a> <a href="/photos/natural-wonders-of-world-18133515"> <div class="relatedphoto"> <img src="http://i.imgur.com/t0vymzs.jpg" alt="thumb 18133515 wallhaven 141502"> <p>natural wonders of world</p> </div> </a> </div>
Comments
Post a Comment