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 610 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..

Pro
Click-type Infinite Scroll in Bricks Builder

Click-type Infinite Scroll in Bricks Builder

This Pro tutorial provides the steps to set up "click to load more" posts using Infinite Scroll JS in Bricks builder. Step 1 Edit your…
Categories:
Pro
Bricks Query Loop Cards with Hover Image

Bricks Query Loop Cards with Hover Image

How images uploaded to posts can appear when the featured images in a Bricks posts query loop are hovered.
Categories:
Pro
Stacking Post Cards in Bricks

Stacking Post Cards in Bricks

How we can stack posts in a query loop so they stick on top of the previous one when scrolling.
Categories:
Tags:
Pro
CSS Grid for Posts Element in Bricks

CSS Grid for Posts Element in Bricks

The "Posts" element in Bricks has "Grid" as the default layout but the actual CSS it applies on the page feels hacky with negative margins…
Categories:
Pro
Image Banner as Query Loop Posts Grid’s Last Item in Bricks

Image Banner as Query Loop Posts Grid’s Last Item in Bricks

In the comments section of How to Insert Element(s) Between Query Loop Posts in Bricks tutorial, a site member asked: This is fantastic! Is there…
Categories:
Tags:
Pro
Filtering Masonry-layout Posts by Categories in Bricks using Isotope

Filtering Masonry-layout Posts by Categories in Bricks using Isotope

Step by step on how to use Isotope in Bricks for filtering posts by categories.
Categories:
How to create filters with IsotopeJS in Bricks (Part 4): AJAX filter and infinite loops, Sorting, List view and Disable animations

How to create filters with IsotopeJS in Bricks (Part 4): AJAX filter and infinite loops, Sorting, List view and Disable animations

This tutorial will explain how to enable the AJAX filter with an infinite scroll query loop container, how to add a sorting function, how to…
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:
Create a App-Like Navigation in Bricks

Create a App-Like Navigation in Bricks

I've promised a few folks in the Facebook group to create a tutorial on how to create an app-like navigation in Bricks like in the…
Categories: