let’s i have the following code http://jsfiddle.net/QhJWt/
<span contentEditable="true">asdfasdf </span>
span
{
height:20px;
width:100px;
border: 1px solid black;
}
how can i emulate textbox behavior? i.e. when text longer then span width it doesnt resizing.
Add
display:blockto yourspanelement, becauseinlineelements ignorewidthandheightproperties. Then, addword-wrap: break-word;, to get the desired behavior.Also, change
heighttomin-height, so that the element resizes when necessary.Fiddle: http://jsfiddle.net/QhJWt/1/