how to word wrap in normal html textbox?

前端 未结 4 1879
挽巷
挽巷 2021-01-21 04:55

i have this text box

Event Data :

相关标签:
4条回答
  • 2021-01-21 05:25

    How about this:

    <p>Event Data:
    <textarea id="data" style="width: 757px; height: 170px" rows="10" cols="80">{{data}}</textarea>
    </p>
    

    Hat tip (and +1) to Stewart for pointing out that rows and cols are required attributes to textarea.

    0 讨论(0)
  • 2021-01-21 05:30

    You will need to use a <textarea> with a wrap attribute. It is not in any HTML standard but to my knowledge the settings "soft", "hard" and "off" work in all major browsers. Definitely in IE. Firefox seems to require a "cols" setting for wrap to work, though.

    0 讨论(0)
  • 2021-01-21 05:32

    If you mean that you want your text values to display as multi-lines, use add a white-space: pre; style to the textarea element, making sure to put put the proper line-breaks into the returned {{data}}

    0 讨论(0)
  • 2021-01-21 05:42
    <p>Event Data:
    <textarea id="data" rows="10" cols="80">{{data}}</textarea>
    </p>
    

    rows and cols are required attributes. Don't ask me why. And if you're going to set the size in CSS, it's generally better to do it in em or % rather than px.

    0 讨论(0)
提交回复
热议问题