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

              
                <h3>Pure CSS "Show More/Less" functionality with Transitions<br>(slideToggle effect with no JavaScript).</h3>

<ul>
  <li><a href="#">One</a></li>
  <li><a href="#">Two</a></li>
  <li><a href="#">Three</a></li>
  <li><a href="#">Four</a></li>
  <li class="container">
    <input type="checkbox" id="check_id">
    <label for="check_id"></label>
    <ul>
      <li><a href="#">Five</a></li>
      <li><a href="#">Six</a></li>
      <li><a href="#">Seven</a></li>
      <li><a href="#">Eight</a></li>
      <li><a href="#">Nine</a></li>
      <li><a href="#">Ten</a></li>
    </ul>
  </li>
</ul>
              
            
!

CSS

              
                * {
  padding: 0;
  margin: 0;
  box-sizing: border-box;
}

body {
  background: #e9ecef;
}

h3 {
  background: #1C1D1F;
  color: white;
  width: 80%;
  text-align: center;
  margin: 15px auto;
  padding: 10px;
}

ul {
  width: 50%;
  margin-left: auto;
  margin-right: auto;
  list-style-type: none;
  background: white;
}

li {
  height: 50px;
  line-height: 50px;
  border-top: 1px solid #e9ecef;
}

ul a {
  display: block;
  height: 100%;
  text-decoration: none;
  color: black;
  padding-left: 10px;
  position: relative;
  transition: background .3s;
}

ul a:after {
  content: '⇢';
  position: absolute;
  right: 10px;
}

ul a:hover {
  background: #cdcbc4;
}
/* CHECKBOX CONTAINER STYLES
–––––––––––––––––––––––––––––––––––––––––––––––––– */

.container {
  position: relative;
  height: auto;
  border-top: 0;
}

[type="checkbox"] {
  position: absolute;
  left: -9999px;
}

label {
  background: #e4e3df;
  display: block;
  width: 100%;
  height: 50px;
  cursor: pointer;
  position: absolute;
  top: 0;
  transition: top .45s cubic-bezier(.44, .99, .48, 1);
}
/*
 * use the rule below for testing purposes
 * label:hover {
 *    background: yellow;
 *  }
 */

label:before,
label:after {
  position: absolute;
}

label:before {
  content: 'More';
  left: 10px;
}

label:after {
  content: '⇣●';
  right: 10px;
  -webkit-animation: sudo .85s linear infinite alternate;
  animation: sudo .85s linear infinite alternate;
}

@keyframes sudo {
  from {
    -webkit-transform: translateY(-2px);
    transform: translateY(-2px);
  }
  to {
    -webkit-transform: translateY(2px);
    transform: translateY(2px);
  }
}

input[type="checkbox"] ~ ul {
  width: 100%;
  overflow: hidden;
  max-height: 0;
  transition: max-height .45s cubic-bezier(.44, .99, .48, 1);
}
/* CHECKED STATE STYLES
–––––––––––––––––––––––––––––––––––––––––––––––––– */

[type="checkbox"]:checked ~ ul {
  /**
   * the value of the `max-height` property specifies the transition speed
   * set a very big value (e.g. 9999px) to see the difference
   */
  
  max-height: 300px;
}

[type="checkbox"]:checked + label {
  top: 100%;
}

[type="checkbox"]:checked + label:before {
  content: 'Less';
}

[type="checkbox"]:checked + label:after {
  content: '⇡●';
}

ul li:last-child {
  margin-bottom: 50px;
}
              
            
!

JS

              
                // Demo by George Martsoukos. 
// See: http://www.sitepoint.com/implementing-show-moreless-functionality-with-pure-css
              
            
!
999px

Console