Creating 15 unique animated buttons with various effects using HTML, jQuery, and CSS3 is a great way to enhance the interactivity and visual appeal of a webpage. Below is a code example for each button, showcasing different animations, colors, and effects:
HTML Structure
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Animated Buttons</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<div class="button-container">
<button class="btn btn-1">Button 1</button>
<button class="btn btn-2">Button 2</button>
<button class="btn btn-3">Button 3</button>
<button class="btn btn-4">Button 4</button>
<button class="btn btn-5">Button 5</button>
<button class="btn btn-6">Button 6</button>
<button class="btn btn-7">Button 7</button>
<button class="btn btn-8">Button 8</button>
<button class="btn btn-9">Button 9</button>
<button class="btn btn-10">Button 10</button>
<button class="btn btn-11">Button 11</button>
<button class="btn btn-12">Button 12</button>
<button class="btn btn-13">Button 13</button>
<button class="btn btn-14">Button 14</button>
<button class="btn btn-15">Button 15</button>
</div>
</body>
</html>
CSS Styling (styles.css)
body {
background-color: #f7f7f7;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
font-family: 'Arial', sans-serif;
}
.button-container {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 20px;
}
.btn {
padding: 10px 20px;
font-size: 18px;
border: 2px solid transparent;
border-radius: 5px;
cursor: pointer;
transition: all 0.3s ease;
position: relative;
overflow: hidden;
z-index: 1;
}
.btn::before, .btn::after {
content: '';
position: absolute;
transition: all 0.3s ease;
z-index: -1;
}
.btn-1 {
background: linear-gradient(45deg, #ff6b6b, #f06595);
color: #fff;
box-shadow: 0px 8px 15px rgba(0, 0, 0, 0.1);
}
.btn-1:hover {
background: linear-gradient(45deg, #f06595, #ff6b6b);
box-shadow: 0px 15px 20px rgba(0, 0, 0, 0.3);
transform: translateY(-3px);
}
/* Button 2 */
.btn-2 {
background: #74b9ff;
color: #fff;
border-radius: 50px;
box-shadow: 0 0 15px rgba(0, 123, 255, 0.4);
}
.btn-2:hover {
box-shadow: 0 0 25px rgba(0, 123, 255, 0.6);
transform: scale(1.1);
}
/* Button 3 */
.btn-3 {
background: #ff9ff3;
color: #fff;
border: 2px solid #ff9ff3;
}
.btn-3:hover {
background: #fff;
color: #ff9ff3;
}
/* Button 4 */
.btn-4 {
background: #2ecc71;
color: #fff;
transform: skew(-10deg);
}
.btn-4:hover {
transform: skew(0deg);
background: #27ae60;
}
/* Button 5 */
.btn-5 {
background: #fdcb6e;
color: #fff;
box-shadow: 0 0 10px rgba(253, 203, 110, 0.5);
}
.btn-5:hover {
box-shadow: 0 0 20px rgba(253, 203, 110, 0.7);
transform: rotate(-10deg);
}
/* Button 6 */
.btn-6 {
background: #55efc4;
color: #fff;
border-radius: 10px;
}
.btn-6:hover {
border-radius: 50px;
transform: scale(1.2);
}
/* Button 7 */
.btn-7 {
background: #ff7675;
color: #fff;
border: 2px solid #ff7675;
}
.btn-7:hover {
background: #fff;
color: #ff7675;
border: 2px solid #ff7675;
}
/* Button 8 */
.btn-8 {
background: #6c5ce7;
color: #fff;
box-shadow: inset 0 0 0 0 #a29bfe;
transition: ease-out 0.4s;
}
.btn-8:hover {
box-shadow: inset 400px 0 0 0 #a29bfe;
}
/* Button 9 */
.btn-9 {
background: #fd79a8;
color: #fff;
border-radius: 50px;
box-shadow: 0px 10px 15px rgba(253, 121, 168, 0.5);
}
.btn-9:hover {
background: #fff;
color: #fd79a8;
}
/* Button 10 */
.btn-10 {
background: #00cec9;
color: #fff;
border-radius: 50%;
}
.btn-10:hover {
transform: scale(1.2);
}
/* Button 11 */
.btn-11 {
background: #0984e3;
color: #fff;
border: 2px solid #0984e3;
}
.btn-11:hover {
background: transparent;
color: #0984e3;
}
/* Button 12 */
.btn-12 {
background: #fdcb6e;
color: #fff;
box-shadow: 0px 4px 15px rgba(0, 0, 0, 0.2);
}
.btn-12:hover {
transform: translateY(-5px);
}
/* Button 13 */
.btn-13 {
background: #6ab04c;
color: #fff;
border: 2px solid #6ab04c;
border-radius: 0;
}
.btn-13:hover {
border-radius: 50px;
transform: rotate(360deg);
}
/* Button 14 */
.btn-14 {
background: #e17055;
color: #fff;
box-shadow: 0px 8px 15px rgba(0, 0, 0, 0.1);
}
.btn-14:hover {
transform: translateY(-5px);
box-shadow: 0px 15px 20px rgba(0, 0, 0, 0.3);
}
/* Button 15 */
.btn-15 {
background: #d63031;
color: #fff;
border-radius: 30px;
box-shadow: 0 0 20px rgba(214, 48, 49, 0.4);
}
.btn-15:hover {
box-shadow: 0 0 30px rgba(214, 48, 49, 0.6);
transform: scale(1.1);
}
jQuery for Additional Animations (Optional)
If you want to add jQuery-based animations, such as triggering animations on click or more complex transitions, you can include a jQuery script.
$(document).ready(function(){
$('.btn').on('click', function(){
$(this).addClass('clicked');
setTimeout(() => {
$(this).removeClass('clicked');
}, 500);
});
});
Explanation:
- Button 1: Gradient background with a subtle box-shadow and a hover effect that changes the gradient direction and shadow.
- Button 2: Circular button with a glowing shadow effect on hover.
- Button 3: Button with a border and background color change on hover.
- Button 4: Skewed button that becomes straight on hover.
- Button 5: Rotating button with a glowing shadow.
- Button 6: Button that changes its border-radius on hover.
- Button 7: Button with border color change on hover.
- Button 8: Button with an inset box-shadow effect that fills on hover.
- Button 9: Rounded button that changes color on hover.
- Button 10: Circular button that scales up on hover.
- Button 11: Button with a border that turns transparent on hover.
- Button 12: Button that elevates slightly on hover.
- **
Button 13**: Square button that becomes circular and rotates on hover.
- Button 14: Button with a shadow effect that intensifies on hover.
- Button 15: Button with a glow effect that scales up on hover.
You can further customize these buttons by modifying the CSS properties to match your desired style and effects.