Getting Started
The HTML Structure
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="style.css">
<title>Glowing Button</title>
</head>
<body>
<div id="container">
<h2>CSS Glowing Button Hover Effect</h2>
<p>Hover over the button to see the glowing effect.</p>
<button id="glowing-button">
Hover Me
</button>
</div>
</body>
</html>
Here, we have a basic HTML template with a button element that has an id called "glowing-button." We've also linked an external CSS file named "style.css."
The CSS
Now, let's create the CSS code to make our button glow when hovered. Create a file named "style.css" and add the following code:
#container {
max-width: 350px;
margin: 20px auto;
color: lightgreen;
padding: 20px;
text-align: center;
background-color: #333;
}
#glowing-button {
padding: 20px;
border-radius: 50em;
font-size: 20px;
font-weight: bold;
border: 5px solid gray;
transition: 0.3s;
background-color: #333;
color: lightgray;
}
#glowing-button:hover {
box-shadow: 0 0 15px 5px rgb(120, 221, 120);
color: rgb(120, 221, 120);
border-color: rgb(120, 221, 120);
cursor: pointer;
}
In this CSS code, we've styled our button and created the glowing effect. When you hover over the button, its background and text color changes to a vibrant green, and it gains a subtle box shadow to create the glowing effect.
Conclusion
That's it! You've successfully created a glowing button hover effect using HTML and CSS. You can further customize this effect by tweaking the colors, sizes, or other properties to match your website's style.
Feel free to experiment and enhance your web development skills by applying this effect to other elements. Web design is all about creativity, so don't hesitate to explore and create your unique designs.
I hope you found this tutorial helpful in understanding how to create a simple yet captivating button hover effect. Happy coding!
Post a Comment