Download "Fit text in box" script

Demo

Put this into your <HEAD> section

Put this into your <BODY> section

How to use

You use this script by defining a <DIV> with an ID. This div should contain one <SPAN> tag which holds the text. Example:
<div id="theBox"><span>www.dhtmlgoodies.com</span></div>
<script type="text/javascript">fitTextInBox('theBox');</script>

The fitTextInBox() function will autofit the text into it's parent DIV. The arguments to this function is the ID of your DIV. The second argument is optional. Use it if you need to define a maximum height. The width of the div is set in the CSS:
  #theBox{
    width:500px;
    border:1px solid #CCC;
    color: #317082;
  }

Comments

Post your comment

Don't have an avatar? Create one at Gravatar.com.

Confirmation code:

Go to cbolson.com


About/Contact | A good idea? | Submit a script | Privacy notice
© 2005 - 2024 dhtmlgoodies.com