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 http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Red Lightsaber</title>
    <link rel="stylesheet" href="style.css">
</head>
<body>
 
    <div class="lightsaber">
        <div class="blade"></div>
        <div class="top"></div>
        <div class="middle"></div>
        <div class="bottom">
            <div class="switch-btn"></div>
        </div>
    </div>

    <script src="main.js"></script>
  <div class="footer"><p>Created by <a href="https://www.rembertdesigns.co/" target="_blank">Richard Rembert</a></p>
      </div>
</body>
</html>
              
            
!

CSS

              
                body{
    margin: 0;
    padding: 0;
    background: black;
}
.lightsaber{
    position: absolute;
    bottom: 3em;
    left: 50%;
    transform: translateX(-50%);
    font-size: 10px;
}
.lightsaber .bottom{
    width: 3em;
    height: 11em;
    background: #c4c4c4;
    position: relative;
}
.lightsaber .bottom::before{
    content: "";
    width: 130%;
    height: 2em;
    position: absolute;
    bottom: 1em;
    left: 50%;
    transform: translateX(-50%);
    background: inherit;
}
.lightsaber .bottom::after{
    content: "";
    width: 100%;
    height: 3em;
    position: absolute;
    bottom: 4em;
    left: 50%;
    transform: translateX(-50%);
    background: #333333;
}
.lightsaber .middle{
    width: 2.6em;
    height: 6em;
    background:
    linear-gradient(
        0deg, #333333
        8%, #8d8d8d 10%, #333333
        12%, #333333 22%, #8d8d8d
        24%, #333333 26%, #333333
        36%, #8d8d8d 38%, #333333
        40%, #333333 50%, #8d8d8d
        52%, #333333 54%, #333333
        64%, #8d8d8d 66%, #333333
        68%, #333333 78%, #8d8d8d
        80%, #333333 82%);
        margin: 0 auto;
        position: relative;
}
.lightsaber .middle::before{
    content: "";
    width: 70%;
    height: 1em;
    position: absolute;
    top: -1em;
    left: 50%;
    transform: translateX(-50%);
    background: #c4c4c4;
}
.lightsaber .top{
    background: #c4c4c4;
    height: 1em;
    width: 3em;
    margin-bottom: 0.8em;
    border-radius: 0 0 1em 1em;
    position: relative;
}
.lightsaber .top::before{
    content: "";
    width: 120%;
    height: 0.5em;
    position: absolute;
    top: -0.5em;
    left: 50%;
    transform: translateX(-50%);
}
.lightsaber .bottom,
.lightsaber .bottom::before,
.lightsaber .top,
.lightsaber .bottom::before,
.lightsaber .middle::before{
    background: 
    linear-gradient(
        90deg, rgba(126,126,126,1) 0%,
        rgba(227,227,227,1)
        20%, rgba(120,120,120,1)
        50%, rgba(227,227,227,1)
        80%, rgba(126,126,126,1) 100%);
}
.lightsaber .blade{
    height: 0;
    width: 1.8em;
    background: #fff;
    border-radius: 2em 2em 0 0;
    margin: 0 auto;
    position: relative;
    transition: 0.4s;
}
.lightsaber .blade::before{
    position: absolute;
    content: "";
    width: 100%;
    height: 100%;
    background: red;
    filter: blur(15px);
    z-index: -1;
}
.lightsaber .bottom .switch-btn{
    position: absolute;
    top: 1em;
    left: 50%;
    transform: translateX(-50%);
    width: 1.5em;
    height: 1.5em;
    border-radius: 50%;
    background: #000;
    cursor: pointer;
}
/*Toggle Class for Javascript*/
.lightsaber .blade-height{
    height: 40em;
}
.footer {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  padding: 1rem;
  background-color: #fff;
  text-align: center;
}
.footer a {
  text-decoration: none;
  color: red;
}
.footer a:hover {
  text-decoration: underline;
  color: #000
}
              
            
!

JS

              
                const blade = document.querySelector('.blade');

document.querySelector('.switch-btn').
addEventListener('click', function() {
    blade.classList.toggle('blade-height');
});
              
            
!
999px

Console