Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<meta charset=utf-8 />
<title>JS Bin</title>
</head>
<body>
  <div id="container">
    <div id="content">
      Text in this div should fit inside the box
    </div>
  </div>
</body>
</html>
 
#container
{
  border:1px solid #cecece;
  width:200px;
  height:150px;
  background:white;
  overflow:visible;
}
#content
{
  font-size:12px;
  font-family:arial;
  font-weight:bold;
  text-align:center;
}
 
$(document).ready(function() {
  maxHeight = $("#container").height();
  lastSize = 9;
  while($("#content").height()<maxHeight && lastSize < 1000)
  {
      lastSize++;
    $("#content").css("font-size", lastSize);
  }
  lastSize--;
  $("#content").css("font-size", lastSize);
});
Output

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

Dismiss x
public
Bin info
anonymouspro
0viewers