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="cover">
<div class="book">
<label for="page-1" class="book__page book__page--1">
<img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/193203/1111.jpg" alt="">
</label>
<label for="page-2" class="book__page book__page--4">
<div class="page__content">
<h1 class="page__content-title">I</h1>
<div class="page__content-blockquote">
<p class="page__content-blockquote-text">HARI SELDON — . . . born in the 11,988th year of the Galactic Era; died 12,069. The dates are more commonly given in terms of the current Foundational Era as -79 to the year 1 F.E. Born to middle-class parents on Helicon, Arcturus sector (where his father, in a legend of doubtful authenticity, was a tobacco grower in the hydroponic plants of the planet), he early showed amazing ability in mathematics. Anecdotes concerning his ability are innumerable, and some are contradictory. At the age of two, he is said to have. . . </p>
<p class="page__content-blockquote-text">. . . Undoubtedly his greatest contributions were in the field of psychohistory. Seldon found the field little more than a set of vague axioms; he left it a profound statistical science. . . . </p>
<p class="page__content-blockquote-text">. . . The best existing authority we have for the details of his life is the biography written by Gaal Dornick who, as a young man, met Seldon two years before the great mathematician's death. The story of the meeting . . .</p>
<span class="page__content-blockquote-reference">Encyclopedia Galactica*</span>
</div>
<div class="page__content-text">
<p>His name was Gaal Dornick and he was just a country boy who had never seen Trantor before. That is, not in real life. He had seen it many times on the hyper-video, and occasionally in tremendous three-dimensional newscasts covering an Imperial Coronation or the opening of a Galactic Council. Even though he had lived all his life on the world of Synnax, which circled a star at the edges of the Blue Drift, he was not cut off from civilization, you see. At that time, no place in the Galaxy was. </p>
<p>There were nearly twenty-five million inhabited planets in the Galaxy then, and not one but owed allegiance to the Empire whose seat was on Trantor. It was the last half-century in which that could be said. </p>
<p>To Gaal, this trip was the undoubted climax of his young, scholarly life. He had been in space before so that the trip, as a voyage and nothing more, meant little to him. To be sure, he had traveled previously only as far as Synnax's only satellite in order to get the data on the mechanics of meteor driftage which he needed for his dissertation, but space-travel was all one whether one travelled half a million miles, or as many light years. </p>
</div>
<div class="page__number">3</div>
</div>
</label>
<!-- Resets the page -->
<input type="radio" name="page" id="page-1"/>
<!-- Goes to the second page -->
<input type="radio" name="page" id="page-2"/>
<label class="book__page book__page--2">
<div class="book__page-front">
<div class="page__content">
<h1 class="page__content-book-title">Foundation</h1>
<h2 class="page__content-author">Isaac Asimov</h2>
<p class="page__content-credits">
Introduction by
<span>Paul Krugman</span>
</p>
<p class="page__content-credits">
Illustrations by
<span>Alex Wells</span>
</p>
<div class="page__content-copyright">
<p>The Folio Society</p>
<p>London - MMXII</p>
</div>
</div>
</div>
<div class="book__page-back">
<div class="page__content">
<h1 class="page__content-title">Contents</h1>
<table class="page__content-table">
<tr>
<td align="left">Part I</td><td align="left">The Psycohistorians</td><td align="right">3</td>
</tr>
<tr>
<td align="left">Part II</td><td align="left">The Encyclopedists</td><td align="right">43</td>
</tr>
<tr>
<td align="left">Part III</td><td align="left">The Mayors</td><td align="right">87</td>
</tr>
<tr>
<td align="left">Part IV</td><td align="left">The Traders</td><td align="right">147</td>
</tr>
<tr>
<td align="left">Part V</td><td align="left">The Merchant Princes</td><td align="right">173</td>
</tr>
</table>
<div class="page__number">2</div>
</div>
</div>
</label>
</div>
</div>
@import url('https://fonts.googleapis.com/css?family=Cormorant+Garamond:300,400,600|Tulpen+One&display=swap');
:root {
/* colors */
--body-bg: #FAFAFA;
--page-bg: #F5F5F5;
--dark-text: #2A2935;
/* spacing */
/* this is what defines the global scale */
--baseline: 12px;
/* fonts */
--book-title: 'Tulpen One', sans-serif;
--title: 'Cormorant Garamond', serif;
--body: 'Cormorant Garamond', serif;
--base-size: var(--baseline) * 1.2;
}
* {
box-sizing: border-box;
}
body {
background-color: var(--body-bg);
height: 100vh;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.cover {
width: calc(var(--baseline) * 60);
height: calc(var(--baseline) * 42.6);
box-shadow: 0 0 100px rgba(0, 0, 0, .3);
}
.book {
width: 100%;
height: 100%;
display: flex;
perspective: 1200px;
&__page {
position: relative;
width: 50%;
height: 100%;
display: grid;
transform: rotateY(0deg);
transition: transform 0.9s cubic-bezier(0.645, 0.045, 0.355, 1);
transform-origin: 0% 0%;
background-color: var(--page-bg);
background-image: linear-gradient(90deg, rgba(227,227,227,1) 0%, rgba(247,247,247,0) 18%);
&:nth-of-type(1) {
background-image: linear-gradient(-90deg, rgba(227,227,227,1) 0%, rgba(247,247,247,0) 18%);
}
&--1 {
cursor: pointer;
overflow: hidden;
img {
width: 100%;
max-width: 100%;
height: auto;
}
}
&--2 {
position: absolute;
right: 0;
pointer-events: none;
transform-style: preserve-3d;
background-color: var(--page-bg);
background-image: linear-gradient(90deg, rgba(227,227,227,1) 0%, rgba(247,247,247,0) 18%);
}
&--4 {
cursor: pointer;
padding: 0 calc(var(--baseline) * 3);
}
&-front {
position: absolute;
width: 100%;
height: 100%;
transform: rotateY(0deg) translateZ(1px);
}
&-back {
position: absolute;
width: 100%;
height: 100%;
padding: 0 calc(var(--baseline) * 1.8);
transform: rotateY(180deg) translateZ(1px);
}
.page__content {
padding: var(--baseline);
height: 100%;
position: relative;
text-align: center;
&-book-title {
font-family: var(--book-title);
font-size: calc(var(--base-size) * 3);
font-weight: bold;
text-transform: uppercase;
letter-spacing: 3px;
color: var(--dark-text);
margin-top: calc(var(--baseline) * 5);
margin-bottom: calc(var(--baseline) * 2);
}
&-author {
font-family: var(--title);
font-size: calc(var(--base-size) * 1.2);
font-weight: 100;
text-transform: uppercase;
color: var(--dark-text);
border-top: 1px solid var(--dark-text);
border-bottom: 1px solid var(--dark-text);
display: inline-block;
padding: calc(var(--baseline) / 2) calc(var(--baseline) / 5);
margin-bottom: calc(var(--baseline) * 6);
}
&-credits {
font-family: var(--title);
text-transform: uppercase;
font-size: calc(var(--base-size) * 0.8);
margin-bottom: calc(var(--baseline) * 2);
letter-spacing: 1px;
span {
display: block;
font-size: calc(var(--base-size) * 1.2);
letter-spacing: 0;
}
}
&-copyright {
position: absolute;
width: calc(100% - (var(--baseline) * 2));
bottom: calc(var(--baseline) * 2);
font-family: var(--title);
font-size: calc(var(--base-size) * 0.8);
text-transform: uppercase;
}
&-title {
font-family: var(--title);
font-size: calc(var(--base-size) * 1);
text-transform: uppercase;
letter-spacing: 1px;
margin-top: calc(var(--baseline) * 5);
margin-bottom: calc(var(--baseline) * 3);
}
&-table {
width: 100%;
margin-top: calc(var(--baseline) * 2);
td {
font-family: var(--title);
font-size: calc(var(--base-size) * 1);
padding-bottom: calc(var(--baseline) * 1.5);
text-transform: uppercase;
}
}
&-blockquote {
margin-bottom: calc(var(--baseline) * 2);
}
&-blockquote-text {
font-family: var(--title);
font-size: calc(var(--base-size) * 0.67);
font-style: italic;
text-align: justify;
}
&-blockquote-reference {
font-family: var(--title);
font-size: calc(var(--base-size) * 0.7);
margin-top: calc(var(--baseline) * 0.3);
float: right;
text-transform: uppercase;
}
&-text {
font-family: var(--title);
font-size: calc(var(--base-size) * 0.67);
text-align: justify;
text-indent: var(--baseline);
}
}
.page__number {
position: absolute;
bottom: var(--baseline);
width: calc(100% - (var(--baseline) * 2));
font-family: var(--title);
font-size: calc(var(--base-size) * 0.67);
text-align: center;
}
}
input[type="radio"] {
display: none;
&:checked+.book__page {
transition: transform 0.9s cubic-bezier(0.645, 0.045, 0.355, 1);
transform: rotateY(-180deg);
}
}
}
// nope
Also see: Tab Triggers