Wednesday, June 14, 2017

How to create hoverable buttons using HTML and CSS

How to create hoverable buttons using HTML and CSS

Hoverable Buttons

Change the button style using the :hover property


Sample code: To Create Hoverable Buttons


<!DOCTYPE html>
<html>
<head>
<style>
    .button
    {
        border: none;
        color: white;
        padding: 14px 28px;
        text-align: center;
        text-decoration: none;
        display: inline-block;
        font-size: 14px;
        margin: 4px 2px;
        cursor: pointer;
        -webkit-transition-duration: 0.4s;
        transition-duration: 0.4s;
    }
    .button:hover { background-color: green; color: white; }
    .button1 { background-color: white; color: black; border: 2px solid green; }
</style>
</head>
<body>
    <h2>Hoverable Buttons</h2>
    <p>Change the button style using the :hover property</p>
    <button class="button button1">Red</button>
</body>
</html>