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 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.
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 esm.sh, which makes packages from npm not only available on a CDN, but prepares them for native JavaScript ESM 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="container">
<h1>A Detailed Summary of Life</h1>
<h4>Quotes from Monty Python's <i>The Meaning of Life</i></h4>
<ul class="timeline">
<li class="timeline">
<div class="icon done"></div>
<details class="panel">
<summary>The Miracle of Birth</summary>
<p><strong>Patient:</strong> Is it a boy or a girl?<br><br>
<strong>Obstetrician:</strong> Now, I think it's a little early to start imposing roles on it, don't you? Now, a word of advice. You may find that you suffer for some time a totally irrational feeling of depression. PND is what we doctors call it. So it's lots of happy pills for you, and you can find out all about the birth when you get home. It's available on Betamax, VHS, and Super 8.</p>
</details>
</li>
<li class="timeline">
<div class="icon done"></div>
<details class="panel">
<summary>Growth and Learning</summary>
<p>And spotteth twice they the camels before the third hour. And so the Midianites went forth to Ram Gilead in Kadesh Bilgemath by Shor Ethra Regalion, to the house of Gash-Bil-Betheul-Bazda, he who brought the butter dish to Balshazar and the tent peg to the house of Rashomon, and there slew they the goats, yea, and placed they the bits in little pots. Here endeth the lesson.</p>
</details>
</li>
<li class="timeline">
<div class="icon working"></div>
<details class="panel">
<summary>Fighting Each Other</summary>
<p>Here is better than home, eh, sir? I mean, at home if you kill someone they arrest you — here they'll give you a gun and show you what to do, sir. I mean, I killed fifteen of those buggers. Now, at home they'd hang me — here they'll give me a fucking medal, sir!</p>
</details>
</li>
<li class="timeline">
<div class="icon"></div>
<details class="panel">
<summary>Middle Age</summary>
<p>It's real Hawaiian food served in an authentic medieval English dungeon atmosphere.</p>
</details>
</li>
<li class="timeline">
<div class="icon"></div>
<details class="panel">
<summary>Live Organ Transplants</summary>
<p>Yeah, I know what it is, but...I'm using it!</p>
</details>
</li>
<li class="timeline">
<div class="icon"></div>
<details class="panel">
<summary>The Meaning of Life</summary>
<p>That’s right, yeah. I’ve had a team working on this over the past few weeks, and what we’ve come up with can be reduced to two fundamental concepts. One, people are not wearing enough hats. Two, matter is energy. In the Universe there are many energy fields which we cannot normally perceive. Some energies have a spiritual source which act upon a person’s soul. However, this soul does not exist ab initio as orthodox Christianity teaches; it has to be brought into existence by a process of guided self-observation. However, this is rarely achieved owing to man’s unique ability to be distracted from spiritual matters by everyday trivia.</p>
</details>
</li>
<li class="timeline">
<div class="icon"></div>
<details class="panel">
<summary>Death</summary>
<p>Well, you're dead now, so shut up.</p>
</details>
</li>
</ul>
</div>
@import url('https://fonts.googleapis.com/css?family=Raleway:400,600');
$wht : #fff;
$blk : #000;
$green : #23b5af;
$yellow : #eeba4c;
$border : lighten($blk,85);
$bg : darken($wht,2);
body{
font-family: 'Raleway', sans-serif;
background:$bg;
}
h1{
text-align: center;
padding:30px 0 0 0;
}
h4{
font-size:1.2em;
text-align: center;
padding:0 0 30px 0;
}
.timeline {
list-style: none;
padding: 20px 0 20px;
position: relative;
&:before {
top: 0;
bottom: 0;
position: absolute;
content: "";
width: 3px;
background-color: $border;
margin-left: -1.5px;
left: 20px;
@media (min-width: 576px) {
left: 50%;
}
}
> li {
margin-bottom: 20px;
position: relative;
padding-left:55px;
&:after, &:after {
content: "";
display: table;
clear: both;
}
.panel {
width: 100%;
float: left;
border-radius: 3px;
overflow:hidden;
position: relative;
background:$wht;
box-shadow: 1px 2px 80px 0 rgba($blk, 0.1);
summary{
display:block;
user-select: none;
outline:none;
padding:20px;
margin-bottom:0px;
transition: all 600ms cubic-bezier(0.23, 1, 0.32, 1);
transition-property: margin, background;
font-weight:600;
&::-webkit-details-marker { display:none; }
&:hover{
background:rgba($blk, 0.1);
}
}
p{
padding:0 20px 10px;
}
&[open] summary{
margin-bottom:20px;
padding-bottom:20px;
border-bottom:1px solid rgba($blk, 0.1);
}
}
@media (min-width: 576px) {
padding-left:0px;
.panel {
width: 50%;
}
&:not(:nth-child(even)) {
padding-right: 90px;
}
&:nth-child(even) {
padding-left: 90px;
> :nth-child(even) {
float: right;
}
}
}
> {
.icon {
color: $border;
width: 50px;
height: 50px;
line-height: 50px;
font-size: 2.5em;
text-align: center;
position: absolute;
left: 20px;
margin-left: -25px;
background-color: $bg;
z-index: 999;
border-radius: 50%;
font-family: Font Awesome\ 5 Free;
&:before{content: "\f192";}
@media (min-width: 576px) {
left: 50%;
}
&.done {
color: $green;
&:before{content: "\f058";}
}
&.working {
color: $yellow;
&:before{content: "\f017";}
}
}
}
}
}
Also see: Tab Triggers