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. 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

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

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

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

              
                
<div class="my-ct">
  
   <a href="https://codepen.io/peterdillon/pen/yoJejJ?level_1=sect1&level_2=sect1a&level_3=sect1a1&cur=hi" class="myLink" target="_top">Click me - A link with PARAMETERS.</a>


  <div id="accordion" class="accordion-group">                
    <div class="panel">

      <a data-toggle="collapse" data-parent="#accordion" data-target="#sect1">
        <h4 class="accordion-title">
          Section 1
        </h4>
      </a>
      <div id="sect1" class="accordion-collapse collapse">
        <p class="a">content 1</p>
        <p>content 1</p>
        <p>content 1</p>

        <a data-toggle="collapse" data-parent="#accordion" data-target="#sect1a">
          <h4 class="accordion-title nest">
            Section 1a
          </h4>
        </a>
        <div id="sect1a" class="accordion-collapse collapse">
          <p class="nest">content 1a</p>
          <p class="nest">content 1a</p>
          
          <a data-toggle="collapse" data-parent="#accordion" data-target="#sect1a1">
            <h4 class="accordion-title nest2">
              Section 1a1
            </h4>
          </a>
          <div id="sect1a1" class="accordion-collapse collapse">
            <p class="nest2 hi">content 1a1</p>
            <p class="nest2">content 1a1</p>
          </div>

          
          
        </div>
        
      </div>

      <a data-toggle="collapse" data-parent="#accordion" data-target="#sect2">
        <h4 class="accordion-title">
          Section 2
        </h4>
      </a>
      <div id="sect2" class="accordion-collapse collapse">
        <p>...</p>
        <p>...</p>
        <p>...</p>
        <p>...</p>
      </div>

      <a data-toggle="collapse" data-parent="#accordion" data-target="#sect3">
        <h4 class="accordion-title">
          Section 3
        </h4>
      </a>
      <div id="sect3" class="accordion-collapse collapse">
        <p>...</p>
        <p>...</p>
        <p>...</p>
        <p>...</p>
      </div>

    </div>
  </div>

</div>
              
            
!

CSS

              
                body {
  background-color: #222;
}
.myLink {
  padding: 1rem;
  display: block;
}
.my-ct {
  width: 30rem;
  margin: .5rem auto;
  background-color: #444;
}
.nest {
  margin-left: 2rem;
}
.nest2 {
    margin-left: 4rem;
  }
a {
  background-color: #999;
  color: #ccc !important;
}
h4, a {
  margin: 0;
  padding: 0;
}
.accordion-title {
  padding: 1rem;
  background-color: #666;
  color: #ccc;
}
p {
  color: #999;
  padding: .75rem;
  margin: 0;
}
.current {
    color: orange !important;
  }

              
            
!

JS

              
                function getUrlParameter(variable) {
   var query = window.location.search.substring(1);
   var vars = query.split("&");
   for (var i=0;i<vars.length;i++) {
           var pair = vars[i].split("=");
           if(pair[0] == variable){return pair[1];}
   }
   return(false);
}

$(document).ready(function() {
    var tester = getUrlParameter("search_query");
  console.log(tester);
    var level_1 = getUrlParameter("level_1");
    var level_2 = getUrlParameter("level_2");
    var level_3 = getUrlParameter("level_3");
    var current = getUrlParameter("cur");
    $("p." + current).addClass("current");
    $('#' + level_1 + '.collapse').collapse('show');
    // Timeout is definitely not necessary, just for ---> a e s t h e t i c
    setTimeout(function() {
      $('#' + level_1 + ' #' + level_2).collapse('show');
    }, 1000);
    setTimeout(function() {
      $('#' + level_1 + ' #' + level_2 + ' #' + level_3).collapse('show');
    }, 2000);
});
              
            
!
999px

Console