We would like to know how to fit images (both landscape and portrait) into square thumbnail.
<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
.thumb {<!--from w w w . j a v a2 s.c o m-->
width: 100px;
height: 100px;
background: center;
background-size: cover;
}
</style>
</head>
<body>
<div class="thumb"
style="background-image: url('http://placehold.it/250x500')"></div>
<br />
<div class="thumb"
style="background-image: url('http://placehold.it/500x200')"></div>
<br />
<div class="thumb"
style="background-image: url('http://placehold.it/100x200')"></div>
</body>
</html>
The code above is rendered as follows: