summaryrefslogtreecommitdiff
path: root/poem.html
blob: 65ad6f537b5532c72cf3d5be369290f0ca570477 (plain)
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
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
  <title>Typing Poem Loop with Background</title>
  <style>
    body {
      background: url('https://www.soonerplantfarm.com/_ccLib/image/plants/DETA-5377.jpg') no-repeat center center fixed;
      background-size: cover;
      color: #fff;
      display: flex;
      justify-content: center;
      align-items: center;
      height: 100vh;
      font-family: monospace;
      font-size: 1.5em;
      padding: 20px;
      text-align: center;
    }

    #overlay {
      background-color: rgba(0, 0, 0, 0.5); /* semi-transparent overlay for readability */
      padding: 20px;
      border-radius: 10px;
    }

    #text {
      white-space: pre-wrap;
      word-break: break-word;
    }

    .cursor {
      display: inline-block;
      width: 10px;
      background-color: #fff;
      margin-left: 2px;
      animation: blink 1s step-start infinite;
    }

    @keyframes blink {
      50% { background-color: transparent; }
    }
  </style>
</head>
<body>
  <div id="overlay">
    <div id="text"></div><div class="cursor"></div>
  </div>

  <script>
    const poem = `And I think it’s time
you had a pink cloud
summer
‘Cause you’ve gone too
long without a smile
I think it’s time you
found another reason to
stay for a while`;

    const textDiv = document.getElementById('text');
    let index = 0;

    function type() {
      if (index < poem.length) {
        textDiv.textContent += poem.charAt(index);
        index++;
        setTimeout(type, 50);
      } else {
        setTimeout(() => {
          textDiv.textContent = "";
          index = 0;
          type();
        }, 2000); // wait 2 seconds before looping again
      }
    }

    type();
  </script>
</body>
</html>