I have this html and css: http://jsfiddle.net/b7rDL/6/
HTML:
<div class="text-block" contenteditable="true" spellcheck="false">Some Text</div>
css:
.text-block {
resize: none;
font-size:40px;
border: none;
line-height: 1;
-moz-appearance: textfield-multiline;
-webkit-appearance: textarea;
min-width: 30px;
overflow: visible;
white-space: nowrap;
display: inline-block;
}
This code allows me to write text with no width limit or height limit. It displays no scroll bar and it grows with the text. Those are basically the features I need.
- How can I convert this to regular textarea that will act the same? I want this to work on browser that doesn’t implemented “contenteditable”. Therefore I want to replace the div with textarea or other basiv element. How can I do it? (I don’t mind using JavaScript).
- How can I disable the spellchecker?
spellcheck=falsedoesn’t work. In the example, when I focus on the text box, I get that buggy red line. I am using Firefox. - How can I get rid of the border when I am focused? – SOLVED
I don’t mind using JavaScript to solve those issues.
Any answer for those questions will help me.
Thanks
UPDATES:
@Oylex helped me with 3
I was having trouble figuring out the bounds of the
textarea‘s content, so with this approach I’m copying the content of thetextareainto a similarly styledpelement, which is set tofloat: left;and then resizing thetextareabased on the size of thep. This handles both width and height.I’ve tested on Mac 10.8.1 FF 18.0, Safari 6.0, Chrome 25.0.1362.0 canary, iOS Safari 6.0.1 and iOS Simulator 5.1 (272.21). I don’t have a PC or IE handy.
http://jsfiddle.net/b7rDL/34/
HTML
CSS
I added a background and border so I could see what’s going on.
JavaScript
I’m adding extra space on the right and at the bottom because it seems to perform more consistently that way. Also, in the HTML, the
wrap="off"is necessary for the version of Firefox, I’m using.I got some good tips from this blog post.