I want to use (div) as a (textarea) element in html. Because when I used (textarea), it's width 开发者_StackOverflowand height was not fixed. I want that when some one open my website they can write something on (div) like what peoples do in Facebook wall. In simple words I want to make wall like Facebook.
Using HTML5, you can use the contenteditable
attribute, e.g.
HTML
<div class="editor" contenteditable="true">
bla bla bla
</div>
This would work how it is, but it should probably have a style, to look and behave nicer. For example:
CSS
div.editor {
width: 200px;
min-height: 50px;
max-height: 100px;
overflow-x: hidden;
overflow-y: auto;
border: 1px solid #303030;
}
This is what Facebook actually does.
min-height
is how big it will start off. Then it will extend up to 100px high, then it will start using a scroll bar, because of overflow-y: auto;
.
You could nest the give your textarea
inside a div
with fixed sizetextarea
a fixed size.
<div style="width: 200px; height: 400px;">
<textarea style="width:100%; height:100%;"></textarea>
</div>
<textarea style="width:200px; height:400px;"></textarea>
With plain html you can only do a static representation of a wall. You'll need a server side language (e.g PHP) and some sort of storage for the wall comments such as files, database (e.g MySQL) etc
精彩评论