Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Glare | CSS</title>
    <link rel="stylesheet" href="style.css">
</head>
<body>
    <div class="social"> Like and <a target="_blank" href="https://twitter.com/miracleio">follow me😁<a> </div>
    <div class="main">
        <div class="cont">
            <button id="button">
                <div class="glare"></div>
                <span>Click Me</span>
            </button>
            <p>Limus Maxima Glare</p>
        </div>

        <div class="cont">
            <button id="button2">
                <div class="glare2"></div>
                <span>Button</span>
            </button>
            <p>3D button Glare</p>
        </div>
    </div>
  
    <script src="./script.js"></script>
</body>
</html>
              
            
!

CSS

              
                @import url('https://fonts.googleapis.com/css?family=Bitter|Noto+Serif|PT+Serif|Roboto+Slab|Work+Sans&display=swap');
@import url('https://fonts.googleapis.com/css?family=Bitter|Noto+Serif|PT+Serif|Roboto+Slab|Work+Sans&display=swap');
* {
    padding: 0;
    margin: 0;
    box-sizing: border-box;
    
  }

  button{
      cursor: pointer;
  }
  
  .main {
    width: 100%;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

.cont{
    width: 200px;
    height: 200px;
    position: relative;
    transform-style: preserve-3d;
    perspective: (700px);
    text-align: center;
    margin:0 10%;
    font-family: 'Bitter', serif;
    font-family: 'PT Serif', serif;
    font-family: 'Roboto Slab', serif;
    //font-family: 'Noto Serif', serif;
    //font-family: 'Work Sans', sans-serif;
    font-weight: 700;
  
    button {
        font-family: 'Work Sans', sans-serif;
        width: 12em;
        height: 5em;
        background: linear-gradient(90deg, #0038ff, #7331ea);
        box-shadow: 0 0 34px -2px rgba(44, 54, 231, 0.45);
        outline: none;
        border: none;
        border-radius: 0.5em;
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%); //rotateY(20deg);
        overflow: hidden;
        &:active{
            transform: translate(-50%, -50%) translateZ(-22px); //rotateY(20deg);
        }
        &:hover .glare{
            opacity: 0.4;
        }

        &:active .glare{
            opacity: 0.4;
            filter: blur(0);
            transform: translate(var(--tx, 0), var(--ty, 0)) scale(2);

        }
        
        .glare{
            width: 50px;
            height: 50px;
            position: absolute;
            transform: translate(var(--tx, 0), var(--ty, 0));
            background: rgb(255, 255, 255);
            opacity: 0;
            border-radius: 50%;
            filter: blur(35px);
            transition: opacity 0.32s cubic-bezier(0.82,-0.87, 0.11, 1.75), filter 0.2s ease, scale 0.12s cubic-bezier(0.79, 0.32, 0.11, 1.75);

          }

        span{
            color: #fff;
            font-size: 18px;
        }
    }
}


#button2{
    width: 14em;
    height: 5em;
    background: linear-gradient(90deg, #2c35f7, #6232ee);    
    box-shadow: 0 0 20px -2px rgba(4, 7, 56, 0.45);
    outline: none;
    border: none;
    border-radius: 0.5em;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotateX(var(--rx, 0)) rotateY(var(--ry, 0)); //rotateY(20deg);
    overflow: hidden;
    transition: 0.22s cubic-bezier(0.34, 0.34, 0.17, 1.55);

    &:hover .glare2{
        opacity: 0.15;
    }

    &:hover span{
        transform: translate(-50%, -50%) rotateX(var(--rx, 0)) rotateY(var(--ry, 0)) translateZ(15px) ; //rotateY(20deg);
    }

    &:active{
        transform:translate(-50%, -50%) rotateX(var(--rx, 0)) rotateY(var(--ry, 0)) translateZ(-20px) ;
    }
    &:active .glare2{
        opacity: 0.25;
    }
    &:active span{
        transform:translate(-50%, -50%) rotateX(var(--rx, 0)) rotateY(var(--ry, 0)) translateZ(40px) ;
    }

    .glare2{
        width: 120px;
        height: 120px;
        top: 50%;
        left: 50%;
        position: absolute;
        transform: translate(-50%, -50%);
        background: rgb(255, 255, 255);
        opacity: 0.1;
        border-radius: 50%;
        filter: blur(30px);
        transition: transform 0.32s ease-out, opacity 0.82s ease;
    
      }
    
    span{
        color: #fff;
        font-size: 18px;
        display: block;
        top: 50%;
        left: 50%;
        position: absolute;
        transform: translate(-50%, -50%);
        transition: 0.32s ease;

    }
}


.social{
      position: fixed;
    bottom: 8%;
    right: 6%;
    text-align: right;
    color: #333;
    font-family: 'Roboto Slab', serif;
    font-weight: 600;
    border-radius: 32px;
    padding: 4px 18px;
    background: linear-gradient(90deg, #8692ff, #b591f7);
    animation: shake 1s linear infinite;
  
  &:hover{
    animation-play-state: paused;
  }
  a{
    text-decoration: overline;
    color: #ddd;
  }
}

@keyframes shake{
  0%{
    transform: translateX(-10px) rotateZ(5deg);
  }
  50%{
    transform: translateX(10px) rotateZ(-5deg);
  }
  100%{
    transform: translateX(-10px) rotateZ(5deg);
  }
}
              
            
!

JS

              
                var button = document.querySelector("button"),
btncoords = button.getBoundingClientRect(),
glare = document.querySelector("button .glare"),
posX, 
posY;

function follow(e){
    posX = ((e.clientX - btncoords.left) - 25) / 1 + "px";
    posY = ((e.clientY - btncoords.top) - 50) / 1 + "px";
    // rotX = ((e.clientX - btncoords.left) - 50) / 8 + "deg";
    // rotY = ((e.clientX - btncoords.top) - 50) / 8 + "deg";


    glare.style.transform = "translate(" + posX + "," + posY + ")";
    // button.style.transform = "rotateY(" + rotY + ")" + "rotateX(" + rotX + ")";
    console.log("translate(" + posX + "," + posY + ")");
}

button.addEventListener('mousemove', follow);

var 
styles = document.documentElement.style;
button2 = document.querySelector("#button2"),
btncoords2 = button2.getBoundingClientRect(),
glare2 = document.querySelector("#button2 .glare2");

function rotate(e){
    console.log({clntX:e.clientX, clntY:e.clientY, scrnX:e.screenX, scrnY:e.screenY});
    var 
    x = e.clientX - btncoords2.left, 
    y = e.clientY - btncoords2.top,
    cx = btncoords2.width / 2,
    cy = btncoords2.height / 2,
    dx = x - cx,
    dy = y - cy;

    console.log({x: x, y: y, cx: cx, cy: cy, dx: dx, dy: dy});

    styles.setProperty("--rx", `${(dy / -1.5)}deg`);
    styles.setProperty("--ry", `${(dx / 10)}deg`);

    // button2.style.transform = "translate(-50%, -50%) rotateX(" + (dy / -2) + "deg) rotateY(" + (dx / 10) + "deg)" 
    glare2.style.transform = "translate(" + (-x / 2) + "%, " + -y + "%)";
};

function restore(e){
    styles.setProperty("--rx", `${0}deg`);
    styles.setProperty("--ry", `${0}deg`);

    // button2.style.transform = "translate(-50%, -50%) rotateX(" + (dy / -2) + "deg) rotateY(" + (dx / 10) + "deg)" 
    glare2.style.transform = "translate(" + (-50) + "%, " + -50 + "%)";
 
}
button2.addEventListener('mousemove', rotate);
button2.addEventListener('mouseleave', restore);

              
            
!
999px

Console