css Audio - Active file-generic CSS - Active Generic - Active HTML - Active JS - Active SVG - Active Text - Active file-generic Video - Active header Love html icon-new-collection icon-person icon-team numbered-list123 pop-out spinner split-screen star tv

Pen Settings

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. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              <div class="text-effect">
  <!-- Select the text in the preview and type in your own -->
  <h1 class="neon" data-text="Neon" contenteditable>Neon</h1>
  <div class="gradient"></div>
  <div class="spotlight"></div>
</div>

            
          
!
            
              // Change the colors
$color1: red;
$color2: blue;

.text-effect {
  overflow: hidden;
  position: relative;
  
  // The blend modes mute the colors, so let's bump them up
  filter: contrast(110%) brightness(190%);
}

.neon {
  position: relative;
  
  // Only works on a black background, sorry
  background: black;
  
  // The actual text inside the div is superfluous, only data-text matters. The text is added so you can easily edit the preview
  color: transparent;
  
  &::before,
  &::after {
    // Add two copies of the text on their own layer
    content: attr(data-text);
    
    // White, so we can paint them later
    color: white;
    
    // And blur them to create the neon effect with the blend-mode below
    filter: blur(0.02em);
    
    position: absolute;
    top: 0; left: 0;
    pointer-events: none;
  }
  
  // Set the top copy to difference. This creates the knock-out effect with a bit of glow
  &::after {
    mix-blend-mode: difference;
  }
}

// Position our two effect layers
.gradient,
.spotlight {
  position: absolute;
  top: 0; left: 0; bottom: 0; right: 0;
  pointer-events: none;
  z-index: 10;  
}

// Add the colors
.gradient {
  background: linear-gradient(45deg, $color1, $color2);
  
  // Multiply mode will paint only the white text
  mix-blend-mode: multiply;
}

.spotlight {
  animation: light 5s infinite linear;
  
  // These are the lights, color-dodge needs a black bg for optimum effect
  background: 
    radial-gradient(circle, white, transparent 25%) 0 0 / 25% 25%, 
    radial-gradient(circle, white, black 25%) 50% 50% / 12.5% 12.5%;
  top: -100%; left: -100%;
  
  // Color dodge gives the lights that shimmer effect
  mix-blend-mode: color-dodge;
}

@keyframes light {
  100% {
    transform: translate3d(50%, 50%, 0);
  }
}

//=== Pen styling, ignore

// Style text
.neon {
  font: 700 220px 'Lato', sans-serif;
  text-transform: uppercase;
  text-align: center;
  margin: 0;
  
  &:focus { outline: none; border: 1px dotted white; }
}

// Center everything
body {
  background: black;
  display: flex;
  min-height: 100vh;
  justify-content: center;
  align-content: center;
  align-items: center;
}
            
          
!
            
              // This is just to auto-update the data-text if you're editing it directly on the page and is not required for the actual effect
$('[data-text]').on('keyup', function(){
  $(this).attr('data-text', $(this).text());
});
            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................

Console