Pen Settings



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


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


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.


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.


                <div class="Widget-Base Widget-MiniFAQ" style="width:95%;">

  <h3>Mini FAQ - Wide view</h3>

    <dt>What is this?</dt>
    <dd> It is an attempt to make a mobile-first, responsive and accessible Mini FAQ.

    <dt>How does it work?</dt>
    <dd><p>Poke around and see for yourself ... but mainly the following: </p>
        <li>Wide FAQs are split left and right</li>
        <li>Narrow ones up and down</li>
        <li>mobile (by window width) do not collapse any questions and show them all. </li>
        Try resizing the output window.</p>

    <dt>Can I help?</dt>
    <dd><p>Sure, if you want to. I'm have pinged stack overflow at <a href=""></a> to see if anyone there has any ideas, but please fork away ... this is a work-in progress and probably has some issues still ;)</p>
        Someone else may already have created something like this ... if you know about it then please say.

    <dt>What does the FAQ look like when there is a very very very very very very very very very very very very very very very very very very very very long question?</dt>
      You're looking at it :D

    <dt>What issues are there currently?</dt>
      <p>There are a few issues I am working on at the mo ... and others I am aware of but may have to be left due to time constraints:</p>
        <li>js could be done better ... first attempt at namespacing</li>
        <li>mobile safari  $(window).width() 320px ?</li>
        <li>on transition from mobile to desktop modes, selected answers not restored.</li>
        <li>there may be a memory leak ... but not sure on that</li>
        <li>aria roles ... or is using dd and dt enough?</li>
        <li>cross browser testing (IE8+, modern ff, gc, op etc.)</li>
        <li>I have thought of making DD visible due to class on its DT, but the logic may me unclear when mixed between CSS and JS</li>

<!-- ######################################### -->

<div class="Widget-Base Widget-MiniFAQ" style="width:300px;">

  <h3>Mini FAQ<br>Narrow view (greeked text)</h3>

  <p>The only difference between this FAQ and the one above is the size of the container.</p>
    <dt>Question 1</dt>
    <dd> 1 Etiam euismod diam vel ultricies consectetur. Nullam sodales mattis mauris at tempus. Proin feugiat mi vitae lacus aliquam sollicitudin. Morbi ullamcorper congue lorem, sit amet consequat nibh iaculis et. 

    <dt>Question 2</dt>
    <dd> 2 Dat nibh iaculis et. Integer sollicitudin neque eget purus eleifend, quis pretium lectus adipiscing. Etiam sit amet mattis lorem. Curabitur molestie malesuada vestibulum. Nullam porttitor in ipsum id fringilla. 

    <dt>Question 3 - long -  lectus adipiscing. Etiam sit amet mattis lorem. Curabitur molestie malesuada vestibulum. Nullam porttitor in ipsum id fringilla.</dt>
      <p>3 Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean et iaculis nunc. Mauris blandit semper purus ac tempus.</p>
      <p>Curabitur porttitor metus sit amet sem hendrerit sagittis. Vestibulum bibendum lectus erat, vel auctor eros condimentum a. </p> 



.Widget-Base {
  padding: 0.8em;
  padding-top: 1em;
  margin: 0;
  margin-bottom: 2em;

  border-top: #7DC243 9px solid;
  border-bottom: #7DC243 1px solid;

.Widget-MiniFAQ * {
  -webkit-box-sizing: border-box; /* Safari/Chrome, other WebKit */
  -moz-box-sizing: border-box;    /* Firefox, other Gecko */
  box-sizing: border-box;         /* Opera/IE 8+ */

  font-family: sans-serif;

.Widget-MiniFAQ {
  content: "> ";

/* Widget css below this line ----------- */

.Widget-MiniFAQ dl a {color: #339;}
.Widget-MiniFAQ dl a:hover {color: #993;}
.Widget-MiniFAQ dt {font-weight: bold; margin: 0.4em 0;}

.Widget-MiniFAQ a {color: #7DC243;}

.Widget-MiniFAQ + dd {display: block !important;}

.Widget-MiniFAQ.TwoCol {
  position: relative;

.Widget-MiniFAQ.TwoCol dl,
.Widget-MiniFAQ.TwoCol dd {
  width: 48%;

.Widget-MiniFAQ.TwoCol dd
  position: absolute;
  top: 0;
  right: 0;
  background: #7DC243;
  padding: 0 0.8em 0.4em;
  overflow: auto;
  border: 0px solid #FFF;
  border-width: 15px 0 0

.Widget-MiniFAQ.TwoCol dd h3 {
  color: #004687;
  padding-bottom: 1em;
  border-bottom: 1px solid #FFF;
  border-color: rgba(255,255,255,0.5);

.Widget-MiniFAQ .AnswerIntro {
  margin: auto;
  text-align: center;



var MiniFAQ = MiniFAQ || {
  settings: {
    mobileRendermodeBreakpoint: 599, // px (make fair size bigger than one col b/p due to bug)
    oneColumnBreakpoint: 400,  //px
    widgetClass: ".Widget-MiniFAQ",
    twoColumnClass: "TwoCol",
    renderMode: "unknown",
    mobile: "m",
    desktop: "d"

  init: function () {

    console.log("init fired");

    // Check if need to trigger mobile view based on viewport width
    this.settings.renderMode = this.getRenderMode();

    if (this.settings.renderMode == {
      console.log("Viewport was too small, mobile view");

    // Init each instance of MiniFAQ
    var faqs = $(this.settings.widgetClass);
    faqs.each(function (i, faq) { MiniFAQ.initFaq($(faq)); });


  getRenderMode: function () {
    if ($(window).width() <= this.settings.mobileRendermodeBreakpoint) {
    return this.settings.desktop;

  initFaq: function (faq) {
    // hide all answers
    $(this.settings.widgetClass + " dd").hide();
    if (faq.width() > this.settings.oneColumnBreakpoint) {
    else {

  initOneCol: function (faq) {
    //faq.prepend("<p class=status>One Column</p>");
    // add links
    faq.find("dt").wrapInner("<a href='#void1'></a>");
    // add handlers
    faq.find('dl').on("click", "dt a", function (e) {

  initTwoCol: function (faq) {
    //faq.prepend("<p class=status>Two Columns</p>");
    // apply styling
    var qs = faq.find("dt");
    // add question to top of each answer
    qs.each(function (i, e) {
      var q = $(e);"dd").prepend("<h3 class='MiniFAQ-QuestionClone'>" + q.text() + "</h3>");
    // add links after setting titles on answers
    qs.wrapInner("<a href='#void2'></a>");
    // apply delegated handlers to entire faq
    faq.find('dl').on("click", "dt a", function (e) {
      // hide all answers
      // show current answer
      var dt = $(this).parent();
    // set height of all absolutely positioned answers to match container
    // if none are active, make first active
    if (faq.find('.active').length == 0) {

  resize: function () {
    console.log("resize fired, width " + $(window).width());
    var newRenderMode = this.getRenderMode();
    if (this.settings.renderMode != newRenderMode) {
      console.warn("renderMode was '" + this.settings.renderMode + "' changed to '" + newRenderMode + "'");
      if (newRenderMode == {

  // Reset funtion for when going from desktop to mobile render mode
  reset: function () {
    console.log("reset fired");
    var w = $(this.settings.widgetClass);
    // remove clones of question in answer for two column items
    // reset height and show
    // remove links
    w.find("dt").each(function (i, e) {
      var dt = $(e);
      var text = dt.text();
    // remove handlers

$(window).ready(function () {

$(window).resize(function () {
  $(this).data('timer', setTimeout(function() {MiniFAQ.resize();}, 300));