Pages

Tuesday, 26 November 2024

Responsive Text Editor




Responsive Text Editor<b><b></b></b>

Responsive Text Editor

body { font-family: Arial, sans-serif; background: linear-gradient(135deg, #ff7eb3, #ff758c); margin: 0; padding: 0; color: white; text-align: center; } .container { max-width: 800px; margin: 50px auto; padding: 20px; background: rgba(255, 255, 255, 0.1); border-radius: 10px; box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3); } h1 { margin-bottom: 20px; } .toolbar { display: flex; justify-content: center; flex-wrap: wrap; gap: 10px; margin-bottom: 20px; } .btn { background: #007bff; border: none; color: white; padding: 10px 15px; border-radius: 5px; cursor: pointer; font-size: 14px; } .btn:hover { background: #0056b3; } #colorPicker, #fontSize { padding: 5px; font-size: 14px; border-radius: 5px; border: 1px solid #007bff; } #editor { border: 2px solid white; min-height: 300px; background: white; color: black; padding: 10px; border-radius: 5px; font-size: 16px; text-align: left; overflow-y: auto; } .download { margin-top: 20px; background: #28a745; color: white; } .download:hover { background: #218838; }// Execute command for toolbar buttons function execCmd(command) { document.execCommand(command, false, null); } // Execute command with arguments (e.g., color, font size) function execCmdWithArg(command, arg) { document.execCommand(command, false, arg); } // Download content as a .txt file document.getElementById('download-btn').addEventListener('click', () => { const text = document.getElementById('editor').innerText; const blob = new Blob([text], { type: 'text/plain' }); const link = document.createElement('a'); link.href = URL.createObjectURL(blob); link.download = 'document.txt'; link.click(); });