26th Nov '22
/
3 comments

Animated Border Hover Effect Buttons

Here’s how

can be implemented in HTML/WordPress/Bricks.

Step 1

Add this CSS in your child theme’s style.css or another appropriate location:

.btn-animated-border {
  position: relative;
  display: inline-block;
  padding: 15px 30px;
  border: 2px solid #111;
  text-transform: uppercase;
  color: #111;
  text-decoration: none;
  font-weight: 600;
  font-size: 20px;
  background-color: transparent;
}

.btn-animated-border::before {
  content: "";
  position: absolute;
  top: 6px;
  left: -2px;
  width: calc(100% + 4px);
  height: calc(100% - 12px);
  background: #fff;
  transition: 0.5s ease-in-out;
  transform: scaleY(1);
}

.btn-animated-border:hover::before {
  transform: scaleY(0);
}

.btn-animated-border:hover::after {
  transform: scaleX(0);
}

.btn-animated-border span {
  position: relative;
  z-index: 3;
}

.btn-animated-border::after {
  content: "";
  position: absolute;
  left: 6px;
  top: -2px;
  height: calc(100% + 4px);
  width: calc(100% - 12px);
  background: #fff;
  transition: 0.5s ease-in-out;
  transform: scalex(1);
}

Step 2

Add a Button element.

Wrap its text with span tags like this:

<span>I am a button</span>

Assign the element a class of btn-animated-border.

If using Bricks, this can be set at STYLE → CSS → CSS classes. You could also simply add it in the element classes input, but make sure you lock it as you don’t want to be accidentally adding/modifying any styles that may affect how these buttons behave.

Get access to all 612 Bricks code tutorials with BricksLabs Pro

3 comments

  • Dee Blight

    Hi Sridhar,

    Would this work with Core Framework? If so, would you be able to show how this would be set up? Also wondering if the background can be transparent too?

    Thank you

    • A

      It should.

      You could create a new selector group and add the above line by line for each property or simply add this in one of the many places where custom CSS can be added in Bricks.

      For transparent background, try setting the value of background property of .btn-animated-border::after to transparent.

  • On black backgrounds you can see white

Leave your comment

 

Related Tutorials..

Custom Animations on Scroll without plugins in Bricks

Custom Animations on Scroll without plugins in Bricks

This tutorial provides the Javascript and CSS codes that can be pasted in order to create custom CSS animations on scroll without any third-party plugins…
Categories:
How to create filters with IsotopeJS in Bricks (Part 3): apply multiple filters

How to create filters with IsotopeJS in Bricks (Part 3): apply multiple filters

This tutorial will review how to apply multiple filters to an isotope container using the IsotopeJS library‘s features in Bricks.
How to add SVG icon as list item bullets

How to add SVG icon as list item bullets

Add this sample CSS: Replace brxe-list with the class of your ul element. Here's how you can generate the value of background-image property: Copy your…
Categories:
Tags:
Pro
Ken Burns Background Slideshow in Bricks

Ken Burns Background Slideshow in Bricks

Setting up a hero section, having images that pan and move as a background slideshow with content on top.
Categories:
Tags:
Width and Height of Mobile Hamburger Toggle in Bricks

Width and Height of Mobile Hamburger Toggle in Bricks

Looking to change the size of Bricks hamburger toggle in the mobile menu? The default width value of 20px can be changed by selecting the…
Categories:
Pro
Meta Box/ACF Images Staggered Grid Gallery in Bricks

Meta Box/ACF Images Staggered Grid Gallery in Bricks

Showing images from two Gallery-type of ACF or Image Advanced-type of Meta Box fields in a staggered grid layout.
Pro
Search Results Template in Bricks

Search Results Template in Bricks

Updated on 26 Oct 2023 This Pro tutorial provides the steps to set up a search template in Bricks with these features: Step 1 Create…
Categories:
Pro
Stripe’s Animated Gradient in Bricks

Stripe’s Animated Gradient in Bricks

This Pro tutorial provides the steps to set up an animated gradient as a background of a section in Bricks using the code generated by…
Categories:
How to create parallax effects using Rellax.js in Bricks

How to create parallax effects using Rellax.js in Bricks

This tutorial provides the JS & PHP codes that can be pasted in order to create smooth parallax effects using the Rellax.js library inside Bricks…
Categories: