A Pen by mode-mercury on CodePen.
Created
October 18, 2025 23:35
-
-
Save mode-mercury/661c1480ae1555698afaafa19f6bdae6 to your computer and use it in GitHub Desktop.
Untitled
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>Letter Spinner</title> | |
| <style> | |
| body { | |
| font-family: Arial, sans-serif; | |
| text-align: center; | |
| margin-top: 50px; | |
| } | |
| .container { | |
| display: flex; | |
| flex-wrap: wrap; | |
| justify-content: center; | |
| gap: 20px; | |
| margin-top: 20px; | |
| } | |
| .letter-container { | |
| width: 100px; | |
| height: 100px; | |
| display: flex; | |
| justify-content: center; | |
| align-items: center; | |
| position: relative; | |
| } | |
| .letter { | |
| font-size: 48px; | |
| font-weight: bold; | |
| } | |
| .spun { | |
| position: absolute; | |
| transform-origin: center; | |
| } | |
| input { | |
| padding: 10px; | |
| font-size: 16px; | |
| width: 300px; | |
| } | |
| button { | |
| margin-top: 10px; | |
| padding: 10px 20px; | |
| font-size: 16px; | |
| cursor: pointer; | |
| } | |
| </style> | |
| </head> | |
| <body> | |
| <h1>Letter Spinner</h1> | |
| <div> | |
| <input type="text" id="phraseInput" placeholder="Enter a phrase"> | |
| <button onclick="spinLetters()">Spin Letters</button> | |
| </div> | |
| <div class="container" id="letterContainers"> | |
| <!-- Letters will be placed here --> | |
| </div> | |
| <script> | |
| function spinLetters() { | |
| const phrase = document.getElementById('phraseInput').value; | |
| const container = document.getElementById('letterContainers'); | |
| container.innerHTML = ''; // Clear previous results | |
| for (let i = 0; i < phrase.length; i++) { | |
| const letter = phrase[i]; | |
| if (letter.trim() === '') continue; // Skip spaces | |
| const letterContainer = document.createElement('div'); | |
| letterContainer.className = 'letter-container'; | |
| // Original letter | |
| const originalLetter = document.createElement('div'); | |
| originalLetter.className = 'letter'; | |
| originalLetter.textContent = letter; | |
| letterContainer.appendChild(originalLetter); | |
| // Four spun instances of the letter | |
| for (let j = 0; j < 4; j++) { | |
| const spunLetter = document.createElement('div'); | |
| spunLetter.className = 'letter spun'; | |
| spunLetter.textContent = letter; | |
| spunLetter.style.transform = `rotate(${90 * j}deg)`; | |
| letterContainer.appendChild(spunLetter); | |
| } | |
| container.appendChild(letterContainer); | |
| } | |
| } | |
| </script> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment