In centered h1
elements, if the text falls on multiple lines, line breaks make the text look like this:
This is a header that takes
I would solve it using only strict JavaScript, going this way:
1. put a class named 'truncate' to h1 tags you want to break
2. configure the javascript code on your needs knowing that
I wrote the code very quickly so it must be better tested for bugs,
but it can be a starting point I think.
I'm not using jQuery in this code to keep the code light and to avoid dependencies.
I think I'm using all cross-browser commands (cannot test it I've got only linux now). However any correction for cross-browser compatibility task (included the use of jQUery if requested) might be easy.
Here is the code:
This is a header that
takes up two lines
This is a header that takes
up three lines because it
is really, really long
This is a header pretty short
or pretty long ... still undecided
which in any case is not truncated!
And here is a demo of that: http://jsfiddle.net/6rtdF/