Shake Invalid Input
CSS
Hard
2 views
Problem Description
Shake an input when it has class 'error'.
Output Format
Print the HTML+CSS code in one block.
Constraints
Use keyframes and apply animation on .error.
Official Solution
<!doctype html>
<html lang='en'>
<head>
<meta charset='utf-8'>
<meta name='viewport' content='width=device-width, initial-scale=1'>
<title>meetcode</title>
<style>
@keyframes shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
input { padding: 10px 12px; border-radius: 12px; border: 1px solid #bbb; }
.error { border-color: #c1121f; animation: shake 300ms ease; }
</style>
</head>
<body>
<input class='error' type='text' value='wrong'>
</body>
</html>
Solutions (0)
No solutions submitted yet. Be the first!
No comments yet. Start the discussion!