Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>JS Bin</title>
</head>
<body>
<div class=frame>
  <img src="https://upload.wikimedia.org/wikipedia/commons/a/a8/Tour_Eiffel_Wikimedia_Commons.jpg"/>
  <span>oversized horizontal image</span>
</div>
<div class=frame>
  <span>oversized vertical image</span>
  <img src="https://upload.wikimedia.org/wikipedia/commons/5/52/Mount_Ellinor,_Mount_Washington_Panorama.jpg"/>
</div>
<div class=frame>
  <span>undersized image</span>
  <img src="http://www.emoji-cheat-sheet.com/graphics/emojis/thumbsup.png"/>
</div>
</body>
</html>
 
.frame {
  height: 160px; /*can be anything*/
  width: 160px; /*can be anything*/
  display: inline-block;
  vertical-align: top; /*not required*/
  border: 1px solid black; /*not required*/
  position: relative;
}
img {
  max-height: 100%;
  max-width: 100%;
  width: auto;
  height: auto;
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  margin: auto;
}
/* everything below is not required */
.frame span {
  font-family: arial, sans-serif;
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  text-align: center;
  color: white;
  background: rgba(0,0,0,0.4);
  font-size: 13px;
}
Output 300px

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
anonymouspro
0viewers