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.
<article class="book-reader">
<input type="checkbox" id="invert">
<input type="checkbox" id="fullscreen">
<label for="invert"></label>
<label for="fullscreen"></label>
<header>
<a href="#home">Home</a>
<h1><a href="#">Book name</a></h1>
</header>
<nav>
<ul>
<li>
<a href="#">previous</a></li>
<li><a href="#">contents</a></li>
<li><a href="#">next</a></li>
</ul>
</nav>
<section>
<div class="page">
<h1> Click the top right buttons!</h1>
<p>Quinoa magna pitchfork pickled food truck, irony cliche single-origin coffee. Irure skateboard gastropub bushwick. Beard mollit wes anderson PBR, food truck reprehenderit fanny pack officia mustache before they sold out. Before they sold out gastropub consectetur ut synth, consequat ethical. Placeat ethnic flexitarian, chillwave laboris mlkshk sartorial cred semiotics odio aute keffiyeh selvage street art. Banh mi placeat adipisicing veniam nostrud, put a bird on it williamsburg eiusmod kogi art party. Assumenda aliqua delectus accusamus.
</p>
<p>
Officia post-ironic VHS, incididunt pork belly single-origin coffee viral mumblecore four loko truffaut. Vice organic hoodie reprehenderit duis pitchfork. Beard raw denim direct trade ea lomo. Lo-fi labore ut, wes anderson nostrud velit blog nisi put a bird on it sartorial commodo stumptown. Authentic sriracha voluptate nisi gastropub. Non adipisicing in, magna twee flexitarian leggings cosby sweater photo booth sartorial farm-to-table fap fixie shoreditch Austin. Est marfa squid, mixtape sed minim fugiat polaroid mcsweeney's sustainable.</p>
<img src="http://theawesomer.com/photos/2010/06/061210_venn_diagram_math_1.jpg" alt="" />
<p>Irure fugiat odd future, marfa eiusmod Austin craft beer aute mumblecore pitchfork banh mi viral helvetica butcher veniam. Chillwave nisi anim kale chips, mcsweeney's photo booth truffaut. Typewriter letterpress next level tumblr, bushwick odio dreamcatcher 3 wolf moon helvetica. Terry richardson beard squid irony, ethnic post-ironic vegan. Ethical pinterest exercitation laborum, aute proident put a bird on it carles magna DIY wayfarers. High life wes anderson polaroid, fanny pack vegan occaecat veniam. Aliquip in helvetica, messenger bag fingerstache put a bird on it lo-fi veniam anim assumenda stumptown.
</p>
<img src="https://d3gqasl9vmjfd8.cloudfront.net/cbd6879c-fcf9-4685-83aa-488e78584eec.png" />
</div>
</section>
</article>
@import "compass/css3";
@import url(https://fonts.googleapis.com/css?family=Open+Sans:400,600);
$grey: #777;
$baseline: 1.75em;
body{
/*for demo only -
this should really be applied to
your container div*/
top:0;
bottom:0;
left:0;
right:0;
position:absolute;
display:block;
height: 100%; width:100%;
margin:0 auto;
overflow:hidden;
position:relative;
position:fixed;
padding:0em;
background-color:#999;
font:{
family:"Open Sans", sans-serif;
weight: 400;
size: 15px;
}
line-height:$baseline;
}
*{box-sizing: border-box; }
/*base style for book and chrome - no magic yet */
.book-reader{
header,nav{user-select:none;}
header{height: $baseline*2;
@include box-shadow(
0 .25em rgba(0,0,0,0.2),
inset 0 -1px rgba(0,0,0,0.6),
inset 0 -2px rgba(255,255,255,0.15));
@include background(
linear-gradient(top ,
lighten(rgba(0,0,0,0.0), 0%) 0%,
darken(rgba(0,0,0,0.4), 10%) 99%));
z-index:99;
position:fixed;
width: 100%;
background-color: #555;
a{line-height:$baseline*2;
text-decoration: none;
display:inline-block;
color :#ccc;
&:hover{
color: white;
}
}
h1{position: absolute;
top:0; margin-left: -3em;
text-align:center; font-weight: 600;
width: 100%;
font-size: $baseline/1.5;
line-height: $baseline;
a{padding:0 1em;
line-height:$baseline;
display:inline;
z-index:9; box-shadow: none;
}
}
a[href="#home"]{
z-index:9;
position:relative;
&:hover{
color:white;
}
@include box-shadow(
inset -1px 0 rgba(255,255,255,0.2),
inset -2px 0 rgba(0,0,0,0.24));
text-align:center;
background-color:rgba(0,0,0,0.13);
display:block;
width: 8em; }
}
nav{
position:absolute;
z-index:8;
bottom:0;
@include background(
linear-gradient(top ,
rgba(0,0,0,0.0) 0%,
rgba(0,0,0,0.4) 100%));
display:table;
width: 100%;
padding:0;
line-height: $baseline*2;
height: $baseline*2;
background:{
color:#ccc;
}
@include box-shadow( 0 -.2em rgba(0,0,0,0.2), 0 -1px rgba(0,0,0,0.16), inset 0 1px rgba(255,255,255,0.3));
color:white;
text-transform: capitalize;
ul{display:table-row;
list-style:none;
margin:0;padding:0;
li{display:table-cell; width: 33.3333%;
a{
color:#333;
text-shadow: 0 1px rgba(255,255,255,0.1);
text-decoration: none;
display:block; width: 100%;
text-align:center; &:hover{
color:white;
background-color: rgba(0,0,0,0.2);;}
}
}
}
}
header, nav{transition: all .2s ease; -webkit-transform: translate3d(0,0,0);}
section{ transition: all .13s ease;
background-color: #fafafa; text-shadow: 0 1px #fff;
position:absolute;
padding: 2em;
overflow: auto;
top: $baseline*2;
bottom: $baseline*2;
width: 90%; left: 5%;
-webkit-transform: translate3d(0,0,0);
*{ -webkit-transform: translate3d(0,0,0);}
@include box-shadow( 0 0 1em rgba(0,0,0,0.4));
@include background(
linear-gradient(left ,
#ddd 0%,
#fafafa 9%,
#fafafa 91%,
#ddd 100%));
-webkit-overflow-scrolling: touch; /*you're welcome tablet users*/
.page{
max-width: 40em;
margin: $baseline auto; }
p{margin: $baseline auto ;
color: #888;
}
h1{
font-size:$baseline*1.5;
color:#555; line-height: $baseline;
font-weight: 300;
}
}
img{
padding:1em;
background-color: white;
box-shadow: 0 .2em .5em rgba(0,0,0,0.2);
width: 100%; }
a{transition: all .15s ease;
@include box-shadow(
inset -1px 0 rgba(255,255,255,0.2),
inset 1px 0 rgba(0,0,0,0.12));}
/*ios hacks*/
a, label, input{-webkit-tap-highlight-color: rgba(0,0,0,0); outline:0;}
nav,header{-webkit-transform:translate3d(0,0,0); label, a{-webkit-transform:translate3d(0,0,0); }}
}
/*
,__ __
/| | | o
| | | __, __, __
| | | / | / | | /
| | |_/\_/|_/\_/|/|_/\___/
/|
\|
Here is the fullscreen magic
You can use this technique to do other magic things like themed styles. scaling text and anything else you can do with css and a toggle to invoke it
*/
label[for="fullscreen"], label[for="invert"]{
transition:all .2s ease;
background-color: rgba(255,255,255,0.05);
position: absolute;
top:0; right:0%;
text-align:center;
padding:0 2em;
z-index:100; color:#aaa;
height: $baseline*2;
cursor:pointer;
width: 11em;
line-height: $baseline*2;
user-select:none;
@include box-shadow(
inset 1px 0 rgba(255,255,255,0.2),
inset 2px 0 rgba(0,0,0,0.2));
&:hover{
background-color: rgba(255,255,255,0.1); color: white;
}
}
#fullscreen{
position:absolute;
top: 0;
z-index:-1;
opacity:0;
/* neighbour selector all up in this*/
&:checked ~ nav{bottom: -$baseline*2;}
&:checked ~ header{top: -$baseline*2;}
&:checked ~ section{top:0; bottom:0;}
&:checked ~ label[for="invert"]{top: -$baseline*2;}
&:checked ~ label[for="fullscreen"]{
width: 7em;
padding:0;
color:#aaa;
background-color:#fff;
@include box-shadow(
inset 0 0 0 1px #fff,
inset 0 0 0 2px #eee,
0 .2em .4em rgba(0,0,0,0.2));
&:before{content: "Exit";}
}
}
label[for="invert"]{
right: 11em;
width: 6em;
}
#invert{
position:absolute;
top: 2em;
z-index:-1;
opacity:0;
&:checked ~ label[for="invert"]{
background-color: rgba(0,0,0,0.35) ;
&:before{
content: "Day"
}
}
&:checked ~ section{
background-image: none;
background-color: #121212 ;
@include box-shadow( 0 0 0 5.5em #111);
color: white;
text-shadow: none;
p, h1{
color: white
}
}
&:checked ~ nav,
&:checked ~ header, { box-shadow: none;
background-color:#222;
color: #777;}
&:checked ~ header a,
&:checked ~ label,
&:checked ~ nav a{color:#777; /* box-shadow: none !important*/;}
}
label[for="fullscreen"]:before{content: "Fullscreen";}
label[for="invert"]:before{content: "Night"; }
/*small size hack*/
@media
(max-width: 50em),
(max-height: 25em)
{
body{font-size:12px; }
}
@media
(max-width: 30em){
.book-reader {
header{
h1{display:none;}
a[href="#home"]{padding: 0 ; width: 5em ;}
}
}
}
// No javascript boieeee
// noScript users rejoice with this functional-ish book reader.
// text from hipsteripsum
Also see: Tab Triggers