smoothley animate a span to fit its text with jquery -


i have created hangman game each letter in span.

html

<span class="letter">a</span> 

css

.letter{     height:40px;     width:40px;     line-height:40px;     text-align:center; } 

after puzzle solved want move letters beside each other form word, need resize span fit text (that 1 letter) avoid spaces. removing class contains height , width results need problem want smoothly.

clone element, set clone width auto , measure width. remove it, , animate original width.

something this:

$('span.letter').each(function(){     var temp = $(this).clone();     $('body').append(temp);     temp.css('width', 'auto');     var newwidth = temp.width();     temp.remove();     $(this).animate('width', newwidth); }); 

Comments

Popular posts from this blog

Winapi c++: DialogBox hangs when breaking a loop -

vb.net - Font adding using PDFsharp -

javascript - jQuery iScroll clickable list elements while retaining scroll? -