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

              
                <!-- 
this is my first pen, i hope you like it.
if you like it make sure to give it a like and give me your thoughts in the comments section bellow :)
if you want to get my updates folow me on twitter: @salihcodes
-->
<div class="container">
  <h1>Button Neon Effect</h1>
  <p>Click on the button if you are on mobile</p>
  <div class="buttons">
    <a href="#" class="neon-button neon-button__1">Hover on me</a>
    <a href="#" class="neon-button neon-button__2">Hover on me</a>
    <a href="#" class="neon-button neon-button__3">Hover on me</a>
  </div>
</div>
              
            
!

CSS

              
                :root {
  --clr-one: rgb(255, 20, 147);
  --clr-two: rgb(127, 255, 0);
  --clr-three: rgb(138, 43, 226);
  --clr-bg: #1d1e22;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
}

body {
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  background: var(--clr-bg);
  font-family: "Balsamiq Sans", cursive;
  overflow: hidden;
}

h1 {
  color: white;
}

p {
  margin-top: 1em;
  color: white;
}

.container {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  flex-direction: column;
  flex-wrap: wrap;
}

.buttons {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
}

.neon-button {
  font-size: 1rem;

  display: inline-block;
  cursor: pointer;
  text-decoration: none;
  padding: 0.5em 1em;
  margin: 2rem;
  border-radius: 0.25em;
  position: relative;
}

.neon-button__1 {
  color: var(--clr-one);
  border: var(--clr-one) 0.125em solid;
  text-shadow: 0 0 0.125em hsl(0 0% 100% / 0.3), 0 0 0.45em --clr-one;
  box-shadow: inset 0 0 0.5em 0 var(--clr-one), 0 0 0.5em 0 var(--clr-one);
}

.neon-button__2 {
  color: var(--clr-two);
  border: var(--clr-two) 0.125em solid;
  text-shadow: 0 0 0.125em hsl(0 0% 100% / 0.3), 0 0 0.45em --clr-two;
  box-shadow: inset 0 0 0.5em 0 var(--clr-two), 0 0 0.5em 0 var(--clr-two);
}

.neon-button__3 {
  color: var(--clr-three);
  border: var(--clr-three) 0.125em solid;
  text-shadow: 0 0 0.125em hsl(0 0% 100% / 0.3), 0 0 0.45em --clr-three;
  box-shadow: inset 0 0 0.5em 0 var(--clr-three), 0 0 0.5em 0 var(--clr-three);
}

.neon-button::before {
  content: "";
  position: absolute;
  top: 120%;
  left: 0;
  width: 100%;
  height: 100%;
  transform: perspective(1.5em) rotateX(45deg) scale(0.8, 0.3);
  filter: blur(1.5em);
  opacity: 0.7;
  pointer-events: none;
}

.neon-button.active::before {
  animation: scalingShadow 0.5s ease-in-out;
}

@keyframes scalingShadow {
  0% {
    top: 120%;
    transform: perspective(1.5em) rotateX(45deg) scale(0.8, 0.3);
  }
  50% {
    top: 165%;
    transform: perspective(1.5em) rotateX(45deg) scale(0.75, 0.3);
  }
  100% {
    top: 120%;
    transform: perspective(1.5em) rotateX(45deg) scale(0.8, 0.3);
  }
}

.neon-button__1::before {
  background: var(--clr-one);
}

.neon-button__2::before {
  background: var(--clr-two);
}

.neon-button__3::before {
  background: var(--clr-three);
}

.neon-button::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  right: 0;
  opacity: 0;
  z-index: -1;
  transition: opacity 100ms linear;
}

.neon-button__1::after {
  box-shadow: 0 0 2em 0.5em var(--clr-one);
  background-color: var(--clr-one);
}

.neon-button__2::after {
  box-shadow: 0 0 2em 0.5em var(--clr-two);
  background-color: var(--clr-two);
}

.neon-button__3::after {
  box-shadow: 0 0 2em 0.5em var(--clr-three);
  background-color: var(--clr-three);
}

.neon-button:hover::before,
.neon-button:focus::before {
  opacity: 1;
}

.neon-button:hover::after,
.neon-button:focus::after {
  opacity: 1;
}

.neon-button:hover,
.neon-button:focus {
  outline: none;
  color: var(--clr-bg);
  text-shadow: none;
}

.active {
  animation: animate 0.5s ease-in-out;
}

@keyframes animate {
  0% {
    transform: translateY(0%);
  }
  50% {
    transform: translateY(-40%);
  }
  100% {
    transform: translateY(0%);
  }
}

              
            
!

JS

              
                const links = document.querySelectorAll("a");

links.forEach((link) => {
  link.addEventListener("click", (event) => {
    event.preventDefault();
    event.target.classList.add("active");
    setTimeout(() => {
      event.target.classList.remove("active");
    }, 500);
  });
});

              
            
!
999px

Console