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.addEventListener('readystatechange', function(){
  if(document.readyState != "complete") return;
  container = document.getElementById('container');
  content = document.getElementById('content');
  maxHeight = container.offsetHeight;
  lastSize = 9;
  while(content.offsetHeight < maxHeight){
    console.log('get',content.offsetHeight);
    content.style['font-size'] = lastSize + 'px';
    lastSize++;
  }
});
Output

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

Dismiss x
public
Bin info
anonymouspro
0viewers