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

              
                <div class="container">
  <div class="px-3 py-3 pt-md-5 pb-md-4 mx-auto text-left">
    <strong class="d-block pb-md-4">solidpixels. <sup class="text-muted">ambasadoři</sup></strong>
    <h1 class="jumbotron-heading pb-md-4">Rozbalovací položky</h1>
    
    <div class="block block-inline">
      <details class="treelist-item">
        <summary>
          <strong class="treelist-title">What is the population of New Orleans?</strong> 
        </summary>
        <div class="treelist-content">According to 2010 Census Bureau estimates, New Orleans' population is made up of approximately 343,829 residents.</div>
      </details>
    </div>

    <div class="block block-inline">
      <details class="treelist-item">
        <summary>
          <strong class="treelist-title">What's a Po' Boy?</strong>   
        </summary>
        <div class="treelist-content">A po' boy (also po-boy, po boy) is a traditional sandwich from Louisiana. It almost always consists of meat, which is usually roast beef or fried seafood, often shrimp, crawfish, fish, oysters or crab.</div>
      </details>
    </div>

    <div class="block block-inline">
      <details class="treelist-item">
        <summary>
          <strong class="treelist-title">How do I get to New Orleans?</strong>
        </summary>
        <div class="treelist-content">Use Google Maps.</div>
      </details>
    </div>
    
    <ul class="pt-md-5">
      <li>Zkopírujte vzorový kód rozklikávací položky:
        <pre style="padding: 1rem; background-color: #efefef;margin: 0.5rem 0;">
&lt;details class="treelist-item">
  &lt;summary>
    &lt;strong class="treelist-title">What is the population of New Orleans?&lt;/strong>
  &lt;/summary>
  &lt;div class="treelist-content">According to 2010 Census Bureau estimates, New Orleans' population is made up of approximately 343,829 residents.&lt;/div>
&lt;/details></pre>
      </li>
      <li>Vložte ukázku jako zdrojový kód do textového bloku.</li>
      <li>Zkopírujte styly LESS a vložte je přes CMS Editor do webu. Pro úpravu vzhledu jsou k dispozici proměnné, které vám umožní libovolně měnit barevnost, odsazení apod.</li>
      <li>Přidejte na sekci třídu <em>section-faq</em>, která odstraní výchozí odsazení textových bloků v sekci
      <li>V moderních prohlížečích bude rozklikávání fungovat bez nutnosti přidávat javascript. Pro starší prohlížeče (IE, Edge) je potřeba napojit fallback.</li>
      <li>Rozbalovací sekce lze rozšířit podle požadavků na accordion či přidat efekty apod.</li>
    </ul>    
  </div>  
</div>


              
            
!

CSS

              
                // VARIABLES

// Treelist: Item
@treelist-item-padding-x:  0.75rem;
@treelist-item-padding-y:  0.4rem;
@treelist-item-color:      #555555;
@treelist-item-background: #ffffff;
@treelist-item-border:     1px solid fade(#000000, 15%);
@treelist-item-spacer-y:   0.5rem;

// Treelist: Item title
@treelist-title-color:        #222222;
@treelist-title-spacer-y:     0.5rem;

// Treelist: Expander icon
@treelist-expander-type:      'chevron-rotate'; // Option: 'none', 'chevron-rotate'
@treelist-expander-position:  right; // Options: left, right
@treelist-expander-size:      18px;

// COMPONENT DEFINITON

// Hide default caret icon
summary {
  cursor: pointer;
  user-select: none;
  outline: none;
  
  &::-webkit-details-marker {
    display: none;
  }
}

.treelist-item {
  padding: @treelist-item-padding-y @treelist-item-padding-x;
  background-color: @treelist-item-background;
  border: @treelist-item-border;
  margin-bottom: @treelist-item-spacer-y;
}

.treelist-title {
  display: block;
  position: relative;
  margin: 0;
  color: @treelist-title-color;
}

// Expander control 
.treelist-title {
  & when (@treelist-expander-type = 'chevron-rotate') {
    &::after {
      position: absolute;
      content: '\f054';
      top: 50%;
      transform: translateY(-50%);
      font-family: FontAwesome;
      font-size: 0.8 * @treelist-expander-size;
      text-align: center;
      width: @treelist-expander-size;
      height: @treelist-expander-size;
      line-height: @treelist-expander-size;
    }
    
    // VARIANT: Icon aligned to the right
    & when (@treelist-expander-position = right) {
      padding-right: 1.5 * @treelist-expander-size;
      
      &::after {
        right: 0;
      }
    } 
    
    & when (@treelist-expander-position = left) {
      padding-left: 1.5 * @treelist-expander-size;
      
      &::after {
        left: 0;
      }
    } 
  }
}

// STATE: Open
.treelist-item[open] {
  .treelist-title {
    margin-bottom: @treelist-title-spacer-y;
  }
  .treelist-title::after when (@treelist-expander-type = 'chevron-rotate') {
    transform: translateY(-50%) rotate(90deg);
    transform-origin: 50%;
  }
}

// Polyfill for IE11 and old FF
.treelist-item[data-open="false"] {
  > *:not(summary) {
    display: none;
  }

  > summary {
    display: block;
  }
}

.treelist-item[data-open="true"] {
  > *:not(summary) {
    display: block;
  }
}

// Pattern (temporary solution to remove default spacing)
.section-faq .block-inline {
  padding: 0;
}
              
            
!

JS

              
                var checkSupportDetails = function() {
  return ('open' in document.createElement('details'));
}

// Fallback initialization
var run_details = function() {
  if (checkSupportDetails()) return;

  var details = document.getElementsByClassName('treelist-item');
  for (var i = 0, l = details.length; i < l; i++) {
    var item = details[i];
    var summary = item.querySelector('.treelist-title');

    item.setAttribute('data-open', 'false');
    summary.addEventListener('click', function(e){
      var element = e.target.parentNode;
      if (element.getAttribute('data-open') === 'true') {
        element.setAttribute('data-open', 'false');  
      }
      else {
        element.setAttribute('data-open', 'true');
      }
    });

  }
}

run_details();


              
            
!
999px

Console