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="wrapper">
  <div class="accordion">
    <h2 class="accordion__heading">History of Football</h2>
    <div class="accordion__list">
      <div class="accordion__item" data-item>
        <div class="accordion__headline" data-toggle>
          <h2 class="accordion__title">Ancient games</h2>
          <span class="icon-circle-carret-right accordion__toggle"></span>
        </div>
        <div class="accordion__content">
          <div class="accordion__inner">
        <p>The Ancient Greeks and Romans are known to have played many ball games, some of which involved the use of the feet.</p><p> The Roman game harpastum is believed to have been adapted from a Greek team game known as "ἐπίσκυρος" (Episkyros)[11][12] or "φαινίνδα" (phaininda),[13] which is mentioned by a Greek playwright, Antiphanes (388–311 BC) and later referred to by the Christian theologian Clement of Alexandria (c. 150 – c. 215 AD). These games appear to have resembled rugby football.</p><p>[14][15][16][17][18] The Roman politician Cicero (106–43 BC) describes the case of a man who was killed whilst having a shave when a ball was kicked into a barber's shop.</p><p>Roman ball games already knew the air-filled ball, the follis.[19][20] Episkyros is recognised as an early form of football by FIFA.[21]</p>
          </div>
        </div>
      </div>
      <div class="accordion__item" data-item>
        <div class="accordion__headline" data-toggle>
          <h2 class="accordion__title">Clubs</h2>
          <span class="icon-circle-carret-right accordion__toggle"></span>
        </div>
        <div class="accordion__content">
          <div class="accordion__inner">
          <p>Sports clubs dedicated to playing football began in the 18th century, for example London's Gymnastic Society which was founded in the mid-18th century and ceased playing matches in 1796.[51][52]</p>

<p>The first documented club to bear in the title a reference to being a 'football club' were called "The Foot-Ball Club" who were located in Edinburgh, Scotland, during the period 1824–41.[53][54] The club forbade tripping but allowed pushing and holding and the picking up of the ball.[54]</p>

<p>In 1845, three boys at Rugby school were tasked with codifying the rules then being used at the school. These were the first set of written rules (or code) for any form of football.[55] This further assisted the spread of the Rugby game.</p>
          </div>
        </div>
      </div>
    </div>
  </div>
</div>
              
            
!

CSS

              
                @import url(https://fonts.googleapis.com/css?family=Merriweather);
$m: 37.5em;
$l: 48em;
$c-cream: #ece9dc;
$c-yellow: #ad9688;
$c-dark: #333;
$c-dark2: #666;

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

//reset

html{
  font-size: 100%;
}

body {
  margin: 0;
  padding: 0;
}

button:focus {
  outline: 0;
}
//extends

.flex-column {
  display: flex;
  flex-direction: column;
}

.flex-center {
  display: flex;
  align-items: center;
  justify-content: center;
}

.fade-in {
  opacity: 1;
  visibility: visible;
}

.fade-out {
  opacity: 0;
  visibilitty: hidden;
}

// @mixin

@mixin transition($prop: all, $time: 0.3s, $type: ease-in-out) {
  transition: $prop $time $type;
}

body {
  font-family: 'Merriweather', serif;
  font-size: 100%;
  line-height: 1.5;
  background: $c-cream;
}

.wrapper {
  padding: 1.5em;
}

.accordion {
  @extend .flex-column;
  flex-wrap: wrap;
  width: 100%;
}

.accordion__heading {
  font-size: 2.2rem;
  line-height: 1;
  margin-bottom: 0.75em;
  padding-top: 0.5em;
  font-weight: 700;
  text-align: center;
}

.accordion__list {
  @extend .flex-column;
  width: 100%;
}

.accordion__item {
  @extend .flex-column;
  @include transition(height);
  position: relative;
  border-bottom: 2px solid $c-dark2;
}

.accordion__headline {
  @extend .flex-center;
  cursor: pointer;
}

.accordion__title {
  flex: 1;
  padding: 1.5em 0;
  font-size: 1rem;
  font-weight: 300;
  line-height: 2;
  text-align: left;
  text-transform: uppercase;
  pointer-events: none;
}

.icon-circle-carret-right {
  display: inline-block;
  width: 2.5em;
  height: 2.5em;
  margin: 1em 0;
  border: 0.05em solid $c-dark;
  text-align: center;
  border-radius: 50%;
  &:after {
    @include transition;
    content: '';
    display: inline-block;
    margin-top: 0.75em;
    margin-right: 0.5em;
    width: 0.75em;
    height: 0.75em;
    border-top: 0.05em solid $c-dark;
    border-right: 0.05em solid $c-dark;
    transform: rotate(45deg);
  }
}

.accordion__content {
  @include transition(transform);
  @extend .fade-out;
  height: 0;
  transform: translateY(-20px);
}

.accordion__inner {
  padding-bottom: 1.5em;
}

.accordion__toggle {
  @include transition;
}

.accordion__item--active {
  .accordion__content {
    @extend .fade-in;
    height: auto;
    transform: translateY(0);
  }
  .accordion__toggle {
    transform: rotate(90deg);
  }
}

              
            
!

JS

              
                var toggles = Array.prototype.slice.call( document.querySelectorAll('[data-toggle]') );
var items = Array.prototype.slice.call( document.querySelectorAll('[data-item]') );

if( toggles && items ) {
  toggles.forEach( function(toggle) {
    toggle.addEventListener('click', function() {
      // Find current active item
      var activeItem = toggle.parentNode;
      // Check if it has active or not
      if( activeItem.classList.contains('accordion__item--active') ) {
        // close a toggle
        closeItem(activeItem);
      } else {
        // first close all another active items
        closeAllItems(items);
        // them open this active item
        openItem(activeItem);
      }
    });
  } );
}

function openItem(item) {
  item.classList.add('accordion__item--active');
}

function closeItem(item) {
  item.classList.remove('accordion__item--active');
}

function closeAllItems(items) {
  items.forEach( function(item) {
    item.classList.remove('accordion__item--active');
  } );
}
              
            
!
999px

Console