HTML preprocessors can make writing HTML more powerful or convenient. For instance, Markdown is designed to be easier to write and read for text documents and you could write a loop in Pug.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. So you don't have access to higher-up elements like the <html>
tag. If you want to add classes there that can affect the whole document, this is the place to do it.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. If you need things in the <head>
of the document, put that code here.
The resource you are linking to is using the 'http' protocol, which may not work when the browser is using https.
CSS preprocessors help make authoring CSS easier. All of them offer things like variables and mixins to provide convenient abstractions.
It's a common practice to apply CSS to a page that styles elements such that they are consistent across all browsers. We offer two of the most popular choices: normalize.css and a reset. Or, choose Neither and nothing will be applied.
To get the best cross-browser support, it is a common practice to apply vendor prefixes to CSS properties and values that require them to work. For instance -webkit-
or -moz-
.
We offer two popular choices: Autoprefixer (which processes your CSS server-side) and -prefix-free (which applies prefixes via a script, client-side).
Any URL's 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 it's URL and the proper URL extention.
You can apply CSS to your Pen from any stylesheet on the web. Just put a URL to it here and we'll apply it, in the order you have them, before the CSS in the Pen itself.
You can also link to another Pen here (use the .css
URL Extension) and we'll pull the CSS from that Pen and include it. If it's using a matching preprocessor, use the appropriate URL Extension and we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
JavaScript preprocessors can help make authoring JavaScript easier and more convenient.
Babel includes JSX processing.
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.
You can apply a script from anywhere on the web to your Pen. Just put a URL to it here and we'll add it, in the order you have them, before the JavaScript in the Pen itself.
If the script you link to has the file extension of a preprocessor, we'll attempt to process it before applying.
You can also link to another Pen here, and we'll pull the JavaScript from that Pen and include it. If it's using a matching preprocessor, we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
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.
Using packages here is powered by Skypack, which makes packages from npm not only available on a CDN, but prepares them for native JavaScript ES6 import
usage.
All packages are different, so refer to their docs for how they work.
If you're using React / ReactDOM, make sure to turn on Babel for the JSX processing.
If active, Pens will autosave every 30 seconds after being saved once.
If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.
If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.
Visit your global Editor Settings.
<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>
@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);
}
}
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');
} );
}
Also see: Tab Triggers