<!DOCTYPE html>
<html> <head> <title>Fancy Font Generator</title> <meta name="viewport" content="width=device-width, initial-scale=1"> <style> body { font-family: Arial, sans-serif; text-align: center; } h1 { margin-top: 50px; font-size: 3em; } #input-text { width: 90%; max-width: 600px; margin: 50px auto; font-size: 1.5em; padding: 10px; border-radius: 10px; border: none; box-shadow: 0 0 5px rgba(0,0,0,0.5); } #output-text { width: 90%; max-width: 600px; margin: 0 auto; font-size: 3em; padding: 20px; border-radius: 10px; border: none; box-shadow: 0 0 5px rgba(0,0,0,0.5); } #change-style-button { display: block; margin: 50px auto; font-size: 1.2em; padding: 10px; border-radius: 10px; border: none; background-color: #f00; color: #fff; cursor: pointer; } @media screen and (max-width: 768px) { #input-text, #output-text { width: 100%; font-size: 1.2em; } #change-style-button { font-size: 1em; } } </style> </head> <body> <h1>Fancy Font Generator</h1> <input type="text" id="input-text" placeholder="Type your text here..."> <div id="output-text"></div> <button id="change-style-button">Change Style</button> <script> const input = document.getElementById('input-text'); const output = document.getElementById('output-text'); const styles = [ { name: 'Fancy', fontFamily: '"Lucida Console", Monaco, monospace', color: '#f00', textShadow: '2px 2px #000, -2px -2px #000, 2px -2px #000, -2px 2px #000', }, { name: 'Serif', fontFamily: 'Georgia, serif', color: '#00f', textShadow: '2px 2px #000', }, { name: 'Sans-serif', fontFamily: 'Helvetica, Arial, sans-serif', color: '#0f0', textShadow: '1px 1px #000, -1px -1px #000', }, { name: 'Script', fontFamily: 'Brush Script MT, cursive', color: '#ff0', textShadow: '2px 2px #000, -2px -2px #000', }, ]; let currentStyleIndex = 0; function applyStyle() { const style = styles[currentStyleIndex]; output.innerHTML = input.value.split('').map(char => `<span class="fancy" style="font-family: ${style.fontFamily}; color: ${style.color}; text-shadow: ${style.textShadow};">${char}</span>`).join(''); } function changeStyle() { currentStyleIndex = (currentStyleIndex + 1) % styles.length; applyStyle(); } applyStyle(); document.getElementById('change-style-button').addEventListener('click', changeStyle); </script> </body> </html>
No comments:
Post a Comment