Search
  • English
Login Register
  • Mon - Sat 11.00 am - 8:00 pm
  • 1st-29, Atlanta Business Hub, VIP Road, Surat
  • +91 97129 28220
Code and Debug
  • Offline Courses
    • C Programming
    • Cpp Programming
    • Django Framework
    • Flutter Development
    • HTML & CSS
    • Javascript
    • MySQL
    • Node.js (Core)
    • Node.js (Advance)
    • Python Programming
  • About Us
  • Contact Us
  • Blog
  • Offline Courses
    • C Programming
    • Cpp Programming
    • Django Framework
    • Flutter Development
    • HTML & CSS
    • Javascript
    • MySQL
    • Node.js (Core)
    • Node.js (Advance)
    • Python Programming
  • About Us
  • Contact Us
  • Blog
Code and Debug > Blog > Frontend > CSS > Button Hover effect purely in HTML & CSS

Button Hover effect purely in HTML & CSS

  • September 25, 2022
  • Posted by: Code and Debug
  • Category: CSS Frontend HTML
No Comments

The code is divided into two parts namely index.html and style.css.

Code for index.html:

				
					<!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>Button Hover Style</title>
    <link rel="stylesheet" href="style.css">
  </head>  
  <body>
    <div class="container">
      <div class="center">
        <button class="btn">
          <svg width="180px" height="60px" viewBox="0 0 180 60" class="border">
            <polyline points="179,1 179,59 1,59 1,1 179,1" class="bg-line" />
            <polyline points="179,1 179,59 1,59 1,1 179,1" class="hl-line" />
          </svg>
          <span>HOVER ME</span>
        </button>
      </div>
    </div>
  </body>
</html>

				
			

Code for style.css:

				
					@import url("https://fonts.googleapis.com/css?family=Lato:100&display=swap");

    body,
    html {
      width: 100%;
      height: 100%;
      margin: 0;
      padding: 0;
      background: white;
      overflow: hidden;
      font-family: "Lato", sans-serif;
    }

    .container {
      width: 400px;
      height: 400px;
      position: absolute;
      left: 50%;
      top: 50%;
      transform: translate(-50%, -50%);
      display: flex;
      justify-content: center;
      align-items: center;
    }

    .center {
      width: 180px;
      height: 60px;
      position: absolute;
    }

    .btn {
      width: 180px;
      height: 60px;
      cursor: pointer;
      background: transparent;
      border: 2px solid rgb(91, 91, 91);
      outline: none;
      transition: 1s ease-in-out;
    }

    svg {
      position: absolute;
      left: 0;
      top: 0;
      fill: none;
      stroke: #fff;
      stroke-dasharray: 150 480;
      stroke-dashoffset: 150;
      transition: 1s ease-in-out;
    }

    .btn:hover {
      transition: 1s ease-in-out;
      background: black;
    }

    .btn:hover svg {
      stroke-dashoffset: -480;
    }

    .btn span {
      color: black;
      font-size: 18px;
      font-weight: 100;
      transition: 0.7s ease-in-out;
    }

    .btn:hover span {
      color: white;
    }
				
			
code css html

Leave a Reply Cancel reply

About US

At Code & Debug, our mission is to continuously innovate the best ways to train the next generation of developers and to transform the the way tech education is delivered.

Code & Debug was founded in 2020 to bridge the knowledge gap between colleges and industry. Founded by Anirudh Khurana, Code & Debug has professional teaching faculty and a state-of-art learning platform for Coding education.
View Courses

Pages

  • About Us
  • Contact Us
  • Home
  • Offline Courses
  • User Account

Contact Us

  • 1st-29, Atlanta Business Hub, VIP Road, Surat
  • Tel.: +91 97129 28220
  • info@codeanddebug.in