Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs 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 its URL and the proper URL extension.

+ 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

Auto Save

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

              
                <div id="cbwrap">
  <!-- (X) NOT IMPORTANT -->
  <h1 id="cbtitle">Fade HTML Elements</h1>

  <!-- (A) CLICK TO FADE -->
  <div id="demoA">Click button to fade.</div>
  <input type="button" value="Toggle" onclick="document.getElementById('demoA').classList.toggle('hide')">

  <hr>
  <!-- (B) HOVER TO FADE -->
  <div id="demoB">Mouse hover to fade.</div>

  <hr>
  <!-- (C) PURE HTML CSS FADE -->
  <label id="demoC" for="demoD">Click to fade.</label>
  <input id="demoD" type="checkbox">
  <div id="demoE">Pure HTML CSS fade.</div>
  
  <!-- (X) NOT IMPORTANT -->
  <div id="cbinfo">Visit <a href="https://code-boxx.com/fade-html-elements/" target="_blank">Code Boxx</a> for more details!</div>
</div>
              
            
!

CSS

              
                /* (A) CLICK TO FADE */
#demoA { transition: opacity 1s; }
#demoA.hide {
  opacity: 0; /* hide */
  height: 0; padding: 0; margin: 0; /* to collapse element */
}

/* (B) HOVER TO FADE */
#demoB { transition: opacity 1s; }
#demoB:hover { opacity: 0; }

/* (C) PURE HTML CSS FADE */
#demoD { display: none; } /* hide checkbox */
#demoE { transition: opacity 1s; }
#demoD:checked + #demoE { opacity: 0; } /* hide when checkbox is checked */

/* (X) NOT IMPORTANT */
hr { margin: 20px 0; }
input[type=button] {
  padding: 10px; margin-top: 10px;
  border: 0;
  color: #fff;
  background: #324ac5;
  cursor: pointer;
}
#demoC { display: block; width: 100%; margin-top: 20px; }
#demoA, #demoB, #demoC, #demoE {
  padding: 10px;
  background: #eee;
}

/* (X) NOT IMPORTANT */
body{background: url(https://images.unsplash.com/photo-1602661287394-ccf02e1a0893?crop=entropy&cs=srgb&fm=jpg&ixid=M3wzMjM4NDZ8MHwxfHJhbmRvbXx8fHx8fHx8fDE3MDAyMzA4NDZ8&ixlib=rb-4.0.3&q=85)}
#cbwrap{background:rgba(255,255,255,.9);width:600px;padding:30px;border-radius:10px}
*{box-sizing:border-box;font-family:arial,sans-serif}
body{padding:0;margin:0;border:0;min-height:100vh;display:flex;justify-content:center;align-items:center;background-size:cover;background-position:center;backdrop-filter:blur(10px)}
#cbtitle{margin:0 0 30px;padding:0;text-transform:uppercase}
#cbinfo{margin-top:30px;padding-top:15px;border-top:1px solid #ddd;font-size:13px;font-weight:700}
#cbinfo a{text-decoration:none;padding:5px;color:#fff;background:#a91616}
              
            
!

JS

              
                
              
            
!
999px

Console