Copied SVG to clipboard
Something went wrong
Copied code to clipboard
Something went wrong
Saved to bookmarks!
Removed from bookmarks
Webflow Challenge: Win $5K

Default

User image

Default

Name

  • -€50
    Upgrade to Lifetime
The Vault/

Button with Slanted Reveal

Button with Slanted Reveal

Documentation

Webflow

Code

Setup: External Scripts

External Scripts in Webflow

Make sure to always put the External Scripts before the Javascript step of the resource.

In this video you learn where to put these in your Webflow project? Or how to include a paid GSAP Club plugin in your project?

HTML

Copy

Step 1: Copy structure to Webflow

Copy structure to Webflow

In the video below we described how you can copy + paste the structure of this resource to your Webflow project.

Copy to Webflow

Webflow structure is not required for this resource.

Step 1: Add HTML

HTML

Copy
<a href="#" class="btn-slanted">
  <div class="btn-slanted-label__wrap">
    <span class="btn-slanted-label">Slanted Button</span>
    <span aria-hidden="true" class="btn-slanted-label">Slanted Button</span>
  </div>
  <div class="btn-slanted-bg"></div>
</a>

HTML structure is not required for this resource.

Step 2: Add CSS

CSS

Copy
.btn-slanted {
  color: #fff;
  background-color: #146ef5;
  border-radius: .125em;
  padding: .625em 1em;
  text-decoration: none;
  position: relative;
  overflow: hidden;
  --rotate: 20deg;
  --move: 150%;
}

.btn-slanted-label__wrap {
  z-index: 1;
  place-items: center;
  display: grid;
  position: relative;
}

.btn-slanted-bg {
  z-index: 0;
  transform-origin: 50% 0;
  border-radius: inherit;
  background-color: #002f79;
  width: 120%;
  height: 100%;
  position: absolute;
  top: auto;
  bottom: 0%;
  right: 0;
  transform: rotate(-30deg)translate(0%, 200%);
  transition: transform 0.45s cubic-bezier(0.625, 0.05, 0, 1);
}

.btn-slanted-label{
  transform-origin: 50% 1000%;
  transition: transform 0.45s cubic-bezier(0.625, 0.05, 0, 1);
}

.btn-slanted-label:not(:nth-of-type(1)){
  position: absolute;
}

.btn-slanted-label:nth-of-type(1){ 
  transform: translate(calc(var(--move) * 0), calc(var(--move) * 0)) rotate(calc(var(--rotate) * 0));
  transition-delay: 0.075s;
}

.btn-slanted-label:nth-of-type(2){ 
  transform: translate(calc(var(--move) * -0.2), calc(var(--move) * 2.5)) rotate(calc(var(--rotate) * -2));
  transition-delay: 0s;
}

/* Hover styles */
@media (hover: hover) {
  .btn-slanted:hover .btn-slanted-label:nth-of-type(1){
    transform: translate(calc(var(--move) * 0.2), calc(var(--move) * -2.5)) rotate(calc(var(--rotate) * 2));
    transition-delay: 0s;
  }
  .btn-slanted:hover .btn-slanted-label:nth-of-type(2){
    transform: translate(calc(var(--move) * 0), calc(var(--move) * 0)) rotate(calc(var(--rotate) * 0));
    transition-delay: 0.075s;
  }
  .btn-slanted:hover .btn-slanted-bg{
    transform: translate(0%, 0%) rotate(0deg);
  }
}

/* Focus styles */
.btn-slanted:focus-visible .btn-slanted-label:nth-of-type(1){
  transform: translate(calc(var(--move) * 0.2), calc(var(--move) * -2.5)) rotate(calc(var(--rotate) * 2));
  transition-delay: 0s;
}
.btn-slanted:focus-visible .btn-slanted-label:nth-of-type(2){
  transform: translate(calc(var(--move) * 0), calc(var(--move) * 0)) rotate(calc(var(--rotate) * 0));
  transition-delay: 0.075s;
}
.btn-slanted:focus-visible .btn-slanted-bg{
  transform: translate(0%, 0%) rotate(0deg);
}

Step 2: Add custom Javascript

Custom Javascript in Webflow

In this video, Ilja gives you some guidance about using JavaScript in Webflow:

Step 2: Add Javascript

Step 3: Add Javascript

Javascript

Copy

Step 3: Add custom CSS

Step 2: Add custom CSS

Custom CSS in Webflow

Curious about where to put custom CSS in Webflow? Ilja explains it in the below video:

CSS

Copy
.btn-slanted{
  --rotate: 20deg;
  --move: 150%;
}

.btn-slanted-label{
  transform-origin: 50% 1000%;
  transition: transform 0.45s cubic-bezier(0.625, 0.05, 0, 1);
}

.btn-slanted-bg{
  transition: transform 0.45s cubic-bezier(0.625, 0.05, 0, 1);
}

.btn-slanted-label:not(:nth-of-type(1)){
  position: absolute;
}

.btn-slanted-label:nth-of-type(1){ 
  transform: translate(calc(var(--move) * 0), calc(var(--move) * 0)) rotate(calc(var(--rotate) * 0));
  transition-delay: 0.075s;
}

.btn-slanted-label:nth-of-type(2){ 
  transform: translate(calc(var(--move) * -0.2), calc(var(--move) * 2.5)) rotate(calc(var(--rotate) * -2));
  transition-delay: 0s;
}

/* Hover styles */
@media (hover: hover) {
  .btn-slanted:hover .btn-slanted-label:nth-of-type(1){
    transform: translate(calc(var(--move) * 0.2), calc(var(--move) * -2.5)) rotate(calc(var(--rotate) * 2));
    transition-delay: 0s;
  }
  .btn-slanted:hover .btn-slanted-label:nth-of-type(2){
    transform: translate(calc(var(--move) * 0), calc(var(--move) * 0)) rotate(calc(var(--rotate) * 0));
    transition-delay: 0.075s;
  }
  .btn-slanted:hover .btn-slanted-bg{
    transform: translate(0%, 0%) rotate(0deg);
  }
}

/* Focus styles */
.btn-slanted:focus-visible .btn-slanted-label:nth-of-type(1){
  transform: translate(calc(var(--move) * 0.2), calc(var(--move) * -2.5)) rotate(calc(var(--rotate) * 2));
  transition-delay: 0s;
}
.btn-slanted:focus-visible .btn-slanted-label:nth-of-type(2){
  transform: translate(calc(var(--move) * 0), calc(var(--move) * 0)) rotate(calc(var(--rotate) * 0));
  transition-delay: 0.075s;
}
.btn-slanted:focus-visible .btn-slanted-bg{
  transform: translate(0%, 0%) rotate(0deg);
}

Implementation

By playing with the transform-origin on our .btn-slanted-label we can create some interesting effects. Almost is if the element is moving alongside a distant 'path'.

Changing transform values

To control the rotation and move value, we've added 2 variables on the .btn-slanted element:

  • --rotate decides the rotation multiplier.
  • --move decides the distance multiplier for both X and Y axis.

We recommend to briefly set overflow: visible on the button while you're tweaking the transform and rotation values on your label. This way, it's much easier to see exactly how the labels move. If you want the exact same --rotate and --move values on all buttons in your site, consider removing them from .btn-slanted and add these variables to your root, so that you have a single place to control them from:

:root{
  --rotate: 20deg;
  --move: 150%;
}

.btn-slanted{
  /* Remove from the button element: 
  --rotate: 20deg;
  --move: 150%;	
  */
}

Resource Details

Button
CSS
Movement
No Javascript
Text Reveal

Original source

Ilja van Eck

Creator Credits

We always strive to credit creators as accurately as possible. While similar concepts might appear online, we aim to provide proper and respectful attribution.