Create index.html
Browse files- templates/index.html +40 -0
templates/index.html
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!-- templates/index.html -->
|
| 2 |
+
<!DOCTYPE html>
|
| 3 |
+
<html lang="ja">
|
| 4 |
+
<head>
|
| 5 |
+
<meta charset="UTF-8">
|
| 6 |
+
<title>画像動かしアプリ</title>
|
| 7 |
+
<style>
|
| 8 |
+
#movable-image {
|
| 9 |
+
position: relative;
|
| 10 |
+
width: 100px; /* 適切なサイズに調整 */
|
| 11 |
+
height: 100px; /* 適切なサイズに調整 */
|
| 12 |
+
}
|
| 13 |
+
</style>
|
| 14 |
+
</head>
|
| 15 |
+
<body>
|
| 16 |
+
<img id="movable-image" src="static/cat.png" alt="動かす画像">
|
| 17 |
+
|
| 18 |
+
<script>
|
| 19 |
+
document.addEventListener('keydown', (event) => {
|
| 20 |
+
const image = document.getElementById('movable-image');
|
| 21 |
+
const keyName = event.key;
|
| 22 |
+
|
| 23 |
+
switch (keyName) {
|
| 24 |
+
case 'ArrowUp':
|
| 25 |
+
image.style.top = (image.offsetTop - 10) + 'px';
|
| 26 |
+
break;
|
| 27 |
+
case 'ArrowDown':
|
| 28 |
+
image.style.top = (image.offsetTop + 10) + 'px';
|
| 29 |
+
break;
|
| 30 |
+
case 'ArrowLeft':
|
| 31 |
+
image.style.left = (image.offsetLeft - 10) + 'px';
|
| 32 |
+
break;
|
| 33 |
+
case 'ArrowRight':
|
| 34 |
+
image.style.left = (image.offsetLeft + 10) + 'px';
|
| 35 |
+
break;
|
| 36 |
+
}
|
| 37 |
+
});
|
| 38 |
+
</script>
|
| 39 |
+
</body>
|
| 40 |
+
</html>
|