Dodging button JS
Inspired by halaltch_unknown
html
2 years ago
2.3 kB
2
Indexable
Never
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> <style> @import url('https://fonts.googleapis.com/css2?family=Roboto&display=swap'); * { margin: 0; padding: 0; box-sizing: border-box; } body { height: 100vh; display: flex; background: rgb(244, 221, 221); background: linear-gradient(275deg, rgba(244, 221, 221, 1) 0%, rgba(186, 12, 12, 1) 100%); } p { color: rgb(223, 223, 223); font-family: 'Roboto'; font-weight: 400; } .msg-box { background-color: #65676B; width: 400px; border-radius: 9999px; padding: 8px; } button { transition: 200ms; border: none; background-color: rgb(70, 144, 255); color: rgb(227, 227, 227); border-radius: 999px; padding: 8px; margin-left: 8px; } .container { display: flex; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); padding: 128px 128px 128px 24px; background-color: #18191A; border-radius: 8px; } </style> </head> <body> <div class="container"> <div class="msg-box"> <p> Inaamin ko, crush na crush kita 😳 <img src="https://cdn.discordapp.com/attachments/792455222655320096/1021574934297841715/emoji.png" style="width: 24px; float: right;"> </p> </div> <button id="btn">Send</button> </div> <script> const btn = document.getElementById('btn'); let position; btn.addEventListener('mouseover', function () { position = position ? 0 : 100; btn.style.transform = 'translate(' + position + 'px,0px)'; }); </script> </body> </html>