My <div>
contains multiple <img>
elements, each wrapped in its own inner <div>
. Despite setting the outer div's height to auto, it fails to adjust dynamically based on the content. To display the inner divs inline, I've applied a float: left
style. However, removing the float allows the outer div to properly adjust its height, but this conflicts with my need for the images to be displayed inline. Any suggestions or solutions would be appreciated.
HTML:
<div id="gallery">
<div class="gal-foto">
<img src="http://farm3.staticflickr.com/2819/10183644713_c1f49eb81f_b.jpg" class="gal-img">
</div>
<div class="gal-foto">
<img src="http://farm4.staticflickr.com/3694/10183642403_0c26d59769_b.jpg" class="gal-img">
</div>
<div class="gal-foto">
<img src="http://farm4.staticflickr.com/3764/10183532675_0ce4a0e877_b.jpg" class="gal-img">
</div>
<div class="gal-foto">
<img src="http://farm6.staticflickr.com/5331/10183598286_9ab37e273c_b.jpg" class="gal-img">
</div>
<div class="gal-foto">
<img src="http://farm6.staticflickr.com/5334/10183535585_04b18fa7da_b.jpg" class="gal-img">
</div>
</div>
CSS:
#gallery {
border: 1px solid;
border-radius: 10px 10px 10px 10px;
box-shadow: 0 0 15px rgba(50, 50, 50, 0.7) inset;
height: auto;
margin-top: 20px;
padding: 15px;
}
.gal-foto {
float: left;
margin: 3px;
position: relative;
}
.gal-img {
display: block;
max-height: 150px;
max-width: 150px;
}