Textarea text area width and height width and height automatic adaptation implementation code

Textarea text area width and height width and height automatic adaptation implementation code

Copy code
The code is as follows:

<HTML>
<HEAD>
<TITLE>Textarea width and height automatic adaptation processing method</TITLE>
<!-- Automatic adaptation of control width-->
<style type="text/css">
.comments {
width:100%;/*Automatically adapt to the width of the parent layout*/
overflow:auto;
word-break:break-all;
/*Solve the line break problem in IE (prevent it from being automatically displayed in one line, mainly to solve the IE compatibility problem. In IE8, when the width is set to 100%, if the text field capacity exceeds one line,
When we double-click the text content, it will automatically change to a single line, so we can only use IE's proprietary line break properties "word-break or word-wrap" to control its line break)*/
}
</style>
</HEAD>

<BODY>
<FORM METHOD=POST ACTION= " ">
<!-- Mainly controls the automatic adaptation of height -->

<!-- The first one is a normal textarea -->
<textarea class="comments" rows="10" cols="10"> </textarea>
<!-- The following two methods can solve the problem of textarea line height automatically adapting to the height of the class content-->
<textarea class="comments" rows=1 name=s1 cols=27 onpropertychange= "this.style.posHeight=this.scrollHeight "></textarea>

<textarea class="comments" style="height:expression((this.scrollHeight>150)?'150px':(this.scrollHeight+5)+'px');overflow:auto;"></textarea>
</FORM>
</BODY>
</HTML>

<<:  Three Discussions on Iframe Adaptive Height Code

>>:  jQuery solves the problem of not executing the original event after adding elements

Recommend

SQL statements in Mysql do not use indexes

MySQL query not using index aggregation As we all...

How to use dl(dt,dd), ul(li), ol(li) in HTML

HTML <dl> Tag #Definition and Usage The <...

Detailed steps for running springboot project in Linux Docker

Introduction: The configuration of Docker running...

Summary of methods for querying MySQL user permissions

Introduce two methods to view MySQL user permissi...

Summary of various forms of applying CSS styles in web pages

1. Inline style, placed in <body></body&g...

Detailed tutorial of using stimulsoft.reports.js with vue-cli

vue-cli uses stimulsoft.reports.js (nanny-level t...

Summarize the User-Agent of popular browsers

1. Basic knowledge: Http Header User-Agent User A...

Vue+ElementUI implements paging function-mysql data

Table of contents 1. Problem 2. Solution 2.1 Pagi...

js development plug-in to achieve tab effect

This article example shares the specific code of ...

Let’s talk in detail about how browsers view closures

Table of contents Preface Introduction to Closure...

Vue3 Vue CLI multi-environment configuration

Table of contents 1. Introduction 2. Switching 1....

Vue implements drag progress bar

This article example shares the specific code of ...

Detailed analysis of each stage of nginx's http request processing

When writing the HTTP module of nginx, it is nece...

W3C Tutorial (1): Understanding W3C

W3C, an organization founded in 1994, aims to unl...