-
Notifications
You must be signed in to change notification settings - Fork 0
/
textarea.html
103 lines (81 loc) · 2.07 KB
/
textarea.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
<!DOCTYPE HTML>
<html>
<head>
<title>Auto-height Textarea</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name='HandheldFriendly' content='True'>
<meta name='MobileOptimized' content='320'>
<meta name='format-detection' content='telephone=no'>
<meta name='viewport' content='width=device-width, minimum-scale=1.0, maximum-scale=1.0'>
<meta http-equiv='cleartype' content='on'>
<link rel='stylesheet' href='style.css'>
<style>
body {
background:#F7F9FA;
}
p {
color:#999;
font-size:11px;
margin:20px;
text-align:center;
}
#textarea-wrap {
background:#fff;
position:relative;
margin:20px;
border:1px #DADDE0 solid;
}
#textarea-wrap textarea,
#textarea-wrap pre {
margin: 0;
padding: 10px;
outline: 0;
border: 0;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
-ms-box-sizing: border-box;
box-sizing: border-box;
background:transparent;
display:block;
font-family:sans-serif;
line-height:1.4;
}
#textarea-wrap textarea {
position:absolute;
top:0;
left:0;
width: 100%;
height:100%;
resize:none;
}
#textarea-wrap pre {
min-height:100px;
visibility:hidden;
}
</style>
</head>
<body>
<div id='textarea-wrap'>
<textarea placeholder='Go ahead, type away...'></textarea>
<pre></pre>
</div>
<p>This is my attempt at the lightest weight autoheight textarea on mobile webkit. It doesn't poll and primarily relies on CSS heights. Only uses a few lines of javascript.</p>
<script>
var wrap = document.getElementById('textarea-wrap'),
ta = wrap.getElementsByTagName('textarea')[0],
pre = wrap.getElementsByTagName('pre')[0];
ta.oninput = function(e) { pre.innerHTML = e.target.value + 8 }
// analytics
var _gauges = _gauges || [];
(function() {
var t = document.createElement('script');
t.async = true;
t.id = 'gauges-tracker';
t.setAttribute('data-site-id', '4eb29910613f5d50ee000002');
t.src = '//secure.gaug.es/track.js';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(t, s);
})();
</script>
</body>
</html>