-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path9.html
More file actions
51 lines (42 loc) · 1.05 KB
/
9.html
File metadata and controls
51 lines (42 loc) · 1.05 KB
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
<!DOCTYPE html>
<html lang="ja" prefix="og: http://ogp.me/ns#">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
<meta name="format-detection" content="email=no,telephone=no,address=no" />
<title>=^.^=</title>
<style>
.inputWrapper {
display: grid;
grid-template-columns: min-content;
}
.inputWrapper::after {
content: attr(data-value) "";
visibility: hidden;
white-space: pre;
grid-area: 0 / 1;
min-width: 1em;
}
.inputWrapper input {
width: 100%;
grid-area: 0 / 1;
padding: 0;
border: 1px solid #ccc;
font: inherit;
}
</style>
<script type="module">
const inputWrapperEl = document.querySelector( '.inputWrapper' );
const inputEl = inputWrapperEl.querySelector( 'input' );
// [1 of 4] input 要素に入力したとき、inputWrapperEl の data 属性にその値をコピーする
inputEl.addEventListener( 'input', () => {
inputWrapperEl.setAttribute( 'data-value', inputEl.value );
} );
</script>
</head>
<body>
<div class="inputWrapper" data-value="">
<input>
</div>
</body>
</html>