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.
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" integrity="sha384-wvfXpqpZZVQGK6TAh5PVlGOfQNHSoD2xbE+QkPxCAFlNEevoEH3Sl0sibVcOQVnN" crossorigin="anonymous">
<div id="wrapper">
<header class="mobile-only" id="mobile-header">
<button id="open-nav" class="mobile-only">
<i class="fa fa-bars"></i>
</button>
<span class="site-title">Frederik Creemers</span>
</header>
<nav id="nav">
<button class="fr mobile-only" id="close-nav">
<i class="fa fa-times"></i>
</button>
<div class="site-title">
Frederik Creemers
<img class="round" src="https://www.gravatar.com/avatar/5e4575fdaacc879dc2199490417d170a?s=200">
</div>
<ul id="menu">
<li>
<a href="/">
Home<i class="fa fa-home"></i>
</a>
</li>
<li>
<a href="/blog">
Blog<i class="fa fa-rss"></i>
</a>
</li>
<li>
<a href="/about">
About<i class="fa fa-user"></i>
</a>
</li>
<li>
<a href="https://github.com/bigblind">
Github<i class="fa fa-github"></i>
</a>
</li>
<li>
<a href="https://twitter.com/_bigblind">
Twitter<i class="fa fa-twitter"></i>
</a>
</li>
</ul>
</nav>
<section id="main">
<h1 class="page-title">
Page title
</h1>
<section>
<h1>A blog post about tech</h1>
<span class="postdate"><i class="fa fa-calendar" aria-hidden></i> February 2nd, 2017</span>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. An vero, inquit, quisquam potest probare, quod perceptfum, quod. Haec quo modo conveniant, non sane intellego. Aliter enim explicari, quod quaeritur, non potest. Sed quid sentiat, non videtis. Duo Reges: constructio interrete. At, illa, ut vobis placet, partem quandam tuetur, reliquam deserit. Legimus tamen Diogenem, Antipatrum, Mnesarchum, Panaetium, multos alios in primisque familiarem nostrum Posidonium. Quae hic rei publicae vulnera inponebat, eadem ille sanabat. Semper enim ita adsumit aliquid, ut ea, quae prima dederit, non deserat. </p>
<p>Et quod est munus, quod opus sapientiae? Quantum Aristoxeni ingenium consumptum videmus in musicis? Sed plane dicit quod intellegit. Quod vestri non item. Dicet pro me ipsa virtus nec dubitabit isti vestro beato M. Quod idem cum vestri faciant, non satis magnam tribuunt inventoribus gratiam. </p>
<p>Ut in voluptate sit, qui epuletur, in dolore, qui torqueatur. An hoc usque quaque, aliter in vita? Tu autem negas fortem esse quemquam posse, qui dolorem malum putet. Ut pulsi recurrant? Piso igitur hoc modo, vir optimus tuique, ut scis, amantissimus. Ergo id est convenienter naturae vivere, a natura discedere. Portenta haec esse dicit, neque ea ratione ullo modo posse vivi; Roges enim Aristonem, bonane ei videantur haec: vacuitas doloris, divitiae, valitudo; </p>
<p>Non dolere, inquam, istud quam vim habeat postea videro; Mihi, inquam, qui te id ipsum rogavi? Et non ex maxima parte de tota iudicabis? Sed ne, dum huic obsequor, vobis molestus sim. Esse enim quam vellet iniquus iustus poterat inpune. </p>
<p><img src="https://thepracticaldev.s3.amazonaws.com/i/ket4231nz0m9ma8kogyf.gif" alt="The illustration shows 3 rectangles representing computer screens. One represents the option to move the screen image "continuously with the pointer". In this mode, the screen moves as soon as the mouse moves. The position of the mouse on the magnified piece of the screen is proportional to the position of the mouse on the full-sized screen. In the "keep pointer centered" mode, the mouse stays centered as long as it is far away enough from the edge. When near the edge, the magnified image stops moving, so the pointer can move away from the center, towards the edge. In the "only move on edges" mode, the magnified portion of the screen doesn't move until the pointer hits one of the edges of the magnified area." /></p>
<p>Si autem id non concedatur, non continuo vita beata tollitur. Non est ista, inquam, Piso, magna dissensio. Bona autem corporis huic sunt, quod posterius posui, similiora. Negat esse eam, inquit, propter se expetendam. Ille vero, si insipiens-quo certe, quoniam tyrannus -, numquam beatus; Non quaeritur autem quid naturae tuae consentaneum sit, sed quid disciplinae. Mihi, inquam, qui te id ipsum rogavi? Potius inflammat, ut coercendi magis quam dedocendi esse videantur. </p>
</section>
</section>
<section id="footer">
© 2017 Frederik Creemers
</section>
</div>
html {
background-color:red;
margin:0;
padding:0;
font-size: 1rem;
position:relative;
width: 100%;
height: 100%;
min-height: 10rem;
}
*, *:before, *:after {
box-sizing: border-box;
}
body {
font-family: "Roboto Slab", "DroidSerif", Cambria, Georgia, "Times New Roman", Times, serif;
font-style:normal;
position:fixed;
left:0;
right:0;
top:0;
bottom:0;
margin: 0;
padding: 0;
background-color: white;
}
#wrapper {
display: flex;
flex-direction:row;
align-items: stretch;
flex-wrap: wrap;
position: absolute;
left: 0;
right: 0;
top: 0;
bottom: 0;
margin: 0;
padding: 0;
overflow: auto;
}
#mobile-header{
width: 100%;
background-color: #3c0000;
color:white;
vertical-align: middle;
padding-left:1rem;
}
#mobile-header button, nav button{
background-color: transparent;
font-size: 2rem;
color: yellow;
border: none;
}
nav {
color: white;
flex: 1;
background-color: #5c0120;
position: relative;
z-index:50;
}
nav button /* The button to close the nav on mobile. */{
margin:1rem;
}
.site-title{
font-size: 2rem;
line-height: 5rem;
text-align:center;
}
#site-title img{
width: 70%;
margin-top:1rem;
}
#main {
flex: 5;
padding: 7rem 5rem;
position: relative;
background-color: #DDD;
z-index: 0;
}
#menu{
list-style:none;
padding:0;
width: 20rem;
position: relative;
float: right;
right: -3rem;
line-height:6rem;
margin-top:4rem;
z-index:100;
}
#menu li{
font-size: 3rem;
border-radius: 3rem;
text-align:right;
display:block;
height: 6rem;
margin-bottom:1rem;
color:white;
}
#menu li a {
color: inherit;
text-decoration: none;
display:block;
}
#menu li:hover {
background-color: white;
color: #5c0120;
}
#menu i{
line-height:5.6rem;
width: 6rem;
height: 6rem;
float: right;
border: 0.2rem solid #5c0120;
border-radius:3rem;
color: #5c0120;
background-color:white;
vertical-align: middle;
text-align: center;
margin-left: 0.5rem;
font-size: 5rem;
transition: transform 1s;
}
#menu li:hover i{
animation: spin 5s linear infinite;
transition: transform 1s;
}
.page-title {
color: #5c0120;
background-color:white;
box-shadow: 0 0.2rem 0.2rem #AAAAAA;
position: absolute;
left:0;
right:0;
top:0;
font-size: 2rem;
margin: 0;
padding-left: 6rem;
line-height: 5rem;
width: auto;
}
#main section{
background-color:white;
padding: 2rem;
}
.postdate{
color: grey;
}
#footer {
width: 100%;
background-color: #4b0009;
color: white;
text-align:center;
padding: 0.5rem;
}
/* Utility classes */
.fw {
width: 100%;
}
.round{
border-radius: 50%;
}
.fr {
float: right;
}
@keyframes spin {
from{
transform: rotate(0deg);
}
to{
transform: rotate(360deg);
}
}
@media (min-width:1001px){
.mobile-only{
display:none !important;
}
}
@media (max-width:1000px){
nav{
position:fixed;
top:0;
left:0;
bottom:0;
transform:translate(-120%, 0);
transition:transform 0.5s;
}
nav.open{
transform: translate(0, 0);
transition: transform 0.5s;
}
#main {
padding: 6rem 1rem;
}
.page-title{
padding-left: 1rem;
}
nav .site-title{
display:none;
}
}
var btn = document.getElementById("open-nav");
var btn2 = document.getElementById("close-nav");
var main = document.getElementById("main");
var nav = document.getElementById("nav");
var toggleNav = function(){
nav.classList.toggle("open");
console.log("toggle");
}
main.addEventListener("click", function(e){
console.log(e.target)
window.bbb = e.target;
if(! (e.target.id === "open-nav" || e.target.parentElement.id === "open-nav")){
nav.classList.remove("open");
}
})
btn.addEventListener("click", toggleNav);
btn2.addEventListener("click", toggleNav);
Also see: Tab Triggers