-
Notifications
You must be signed in to change notification settings - Fork 57
/
Copy pathindex.html
59 lines (50 loc) · 2.05 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>textarea-autosize by javierjulio</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="/normalize.css">
<link rel="stylesheet" href="/demo.css">
</head>
<body>
<div class="container">
<h1 class="logo">Textarea AutoSize</h1>
<p class="margin-bottom-5x">With <a href="https://github.com/javierjulio/textarea-autosize">textarea-autosize</a> it can vertically adjust a textarea based on user input while all presentation is controlled through CSS. <strong>No clone or ghost elements</strong> used. No jQuery either. Just plain vanilla JS. 😉</p>
<nav class="demo-options js-textarea-demo-options">
<a href="#">Single Line</a>
<a href="#">Multiple Lines</a>
<a href="#">Prefilled</a>
</nav>
<div class="margin-bottom-5x">
<textarea data-testid="sample-textarea" class="single-line js-auto-size" rows="1" autofocus></textarea>
</div>
<p>The sample code assumes a single line is the default.</p>
<p>Sample HTML:</p>
<div><pre><textarea class="js-auto-size" rows="1"></textarea>
<script type="module">
import { TextareaAutoSize } from './src/textarea-autosize.js'
const wrapper = new TextareaAutoSize(
document.querySelector('textarea.js-auto-size')
)
</script>
</pre></div>
<p>Sample CSS:</p>
<div><pre>textarea {
box-sizing: border-box;
max-height: 160px; // optional but recommended
min-height: 38px;
}
</pre></div>
<p class="margin-bottom-5x">The min and max height in the sample CSS is a pre-calculated value. If your font-size is 16px, line-height is 1.5 and top/bottom padding is 6px each, then the minimum height would be 36px since 16 * 1.5 + 12 = 36.</p>
<footer class="site-footer text-center">
<p>
<a href="https://github.com/javierjulio/textarea-autosize">
View the textarea-autosize project on GitHub
</a>
</p>
</footer>
</div>
<script type="module" src="./index.js"></script>
</body>
</html>