Created
April 14, 2015 08:45
-
-
Save clathrop/19225a305a917c6ba861 to your computer and use it in GitHub Desktop.
cropped square thumbnails with twitter bootstrap & css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- HTML --> | |
<div class="col-sm-6"> | |
<a href="#" class="thumbnail"> | |
<div class="caption"> | |
title<br/>3 x bekeken | |
</div> | |
<div class="image"> | |
<img src="" class="img img-responsive full-width" /> | |
</div> | |
</a> | |
</div> | |
.image{ | |
position:relative; | |
overflow:hidden; | |
padding-bottom:100%; | |
} | |
.image img{ | |
position:absolute; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Padding top/bottom (like margin top/bottom) is calculated according to the width of parent element.As the .image div has the same width as its parent, setting padding-bottom:100%; give it the same height as its width so it is square (its content needs to be absolutely positioned or floated so it doesn't change the parent's size).