I'm coming up against a common problem with customised content management system design.
I run a small web design company and I often have to make a certain area of a website editable for the customer. For example, there may be a bar along the top of the page advertising the latest news or deals which the customer wants to be able to edit themselves.
The problem I'm having is that they often write too much and the text overflows. Maybe I'm being a bit too defensive, but in these situations I usually privately blame the customer - surely they check after updating the text, realise it doesn't fit, and modify it so that it does?
Anyway, I guess it's my responsibility to make the site look nice so I've been trying to find a way of making text fit in a fixed size box. One way is to give the box (usually a div
) this css property:
overflow: auto;
but sometimes this isn't suitable, such as in the example described above where the bar is only one line high.
My question (yes I've finally got to it) is how can I make the font change size automatically so that it fits in the box?
In some applications (Powerpoint being one example), you can choose a "best fit" option for font size and the application chooses a size which allows the text to fit exactly. I'm basically looking for either a CSS, JavaScript or PHP version of this.
Thanks in advance!
EDIT: Here's the solution - http://jsfiddle.net/Cnkfn/1/