Back
Unlock creativity with a playful, floating input field that adapts its shape and size as you type.
<div class="bubble-wrapper"> <input type="text" class="floating-input" placeholder="Type your feedback here..."> </div>
document.querySelector('.floating-input').addEventListener('input', function() { let input = document.querySelector('.floating-input'); let valueLength = input.value.length; input.style.width = Math.min(valueLength * 10 + 50, 300) + 'px'; input.style.height = Math.min(valueLength * 5 + 20, 150) + 'px'; });
.bubble-wrapper { position: relative; display: flex; justify-content: center; align-items: center; height: 200px; } .floating-input { width: 50px; height: 30px; padding: 10px; border: none; border-radius: 50px; box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1); background: rgba(255, 255, 255, 0.15); backdrop-filter: blur(10px); transition: width 0.3s ease, height 0.3s ease; font-size: 1rem; font-family: 'Arial', sans-serif; color: #333; outline: none; }In this way, we are able to design an interactive input field using innovative technology trends like glassmorphism. Your feedback inputs now float and expand as you type, offering an intriguing user experience.
<div class="bubble-wrapper"> <input type="text" class="floating-input" placeholder="Type your feedback here..."> </div> <script> document.querySelector('.floating-input').addEventListener('input', function() { let input = document.querySelector('.floating-input'); let valueLength = input.value.length; input.style.width = Math.min(valueLength * 10 + 50, 300) + 'px'; input.style.height = Math.min(valueLength * 5 + 20, 150) + 'px'; }); </script> <style> .bubble-wrapper { position: relative; display: flex; justify-content: center; align-items: center; height: 200px; } .floating-input { width: 50px; height: 30px; padding: 10px; border: none; border-radius: 50px; box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1); background: rgba(255, 255, 255, 0.15); backdrop-filter: blur(10px); transition: width 0.3s ease, height 0.3s ease; font-size: 1rem; font-family: 'Arial', sans-serif; color: #333; outline: none; } </style>Thank you for reading this article.
Comments