JavaScript preprocessors can help make authoring JavaScript easier and more convenient. For instance, CoffeeScript can help prevent easy-to-make mistakes and offer a cleaner syntax and Babel can bring ECMAScript 6 features to browsers that only support ECMAScript 5.
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.
HTML Settings
Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.
<div class="container">
<div class="section">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>
</div>
<div class="section collapsible">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
</div>
<div class="section">
<p>Ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>
</div>
</div>
<button id="toggle-button">Toggle collapse</button>
// This stuff matters!
.container {
display:flex;
flex-direction:column;
justify-content:flex-start;
height:600px; // sadly, we're required to set at least the container height explicitly
}
.section {
overflow:hidden;
transition:flex 0.3s ease-out; // note that we're transitioning flex, not height!
height:auto;
flex:1;
}
.section.collapsed {
flex: 0;
}
// This stuff doesn't matter!
* {
box-sizing:border-box;
}
body {
margin:0;
padding:10vh 10vw;
font-family:arial;
}
p {
margin:10px;
}
.container {
border: 3px solid #FFEB3B;
margin:0 auto;
max-width:300px;
border-radius:3px;
.section {
border:3px solid #4CAF50;
}
}
button {
display:block;
--webkit-appearance:none;
font-size:18px;
border:none;
border-radius:3px;
background:#2196F3;
color:white;
margin:15px auto;
padding:15px;
cursor:pointer;
transition:box-shadow 0.2s ease-out;
&:hover {
box-shadow:0px 0px 15px lightgrey;
}
&:active {
box-shadow:0px 0px 10px lightgrey;
}
&:focus {
outline:none;
}
}
// Look ma, [very little] Javascript!
document.querySelector('#toggle-button').addEventListener('click', function() {
document.querySelector('.section.collapsible').classList.toggle('collapsed');
});
Also see: Tab Triggers