Steven Zack
Steven Zack

Reputation: 5114

how to make text wrap when the length of text over length of div?

I need to append text user entered into a fixed width and height div. I set the div overflow:auto, but I only want to show vertical scrollbar, don't want to see the horizontal one. How to make the text wrap automatically to fix the width of div?

<script>
function Send(){
    var text=$("[id$='Text1']").val();
    $('#contentDIV').append("me:    "+text+"<br />");
}
</script>

Upvotes: 1

Views: 2719

Answers (2)

MatTheCat
MatTheCat

Reputation: 18761

The text will wrap unless a word is longer than your div can content. In this case you just have word-break (CSS3).

Upvotes: 1

amosrivera
amosrivera

Reputation: 26554

div{
    width:400px;
    height:400px;
    overflow-y:auto;
}

online demo: http://jsfiddle.net/3CQmP/

Upvotes: 4

Related Questions