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.
<nav data-html2canvas-ignore class="composite navbar navbar-flush navbar-fixed-top">
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display-->
<div class="navbar-header">
<button class="navbar-toggle collapsed" type="button" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false"><span class="sr-only">Toggle navigation</span><span class="icon-bar"></span><span class="icon-bar"></span><span class="icon-bar"></span></button><a class="navbar-brand ion-ios-infinite" href="#"></a>
</div>
<!-- Collect the nav links, forms, and other content for toggling-->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li class="active"><a href="#">Link <span class="sr-only">(current)</span></a></li>
<li><a href="#">Link</a></li>
<li class="dropdown"><a class="dropdown-toggle" href="#" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Dropdown <span class="ion-ios-arrow-down"></span></a>
<ul class="dropdown-menu">
<li><a href="#">Action</a></li>
<li><a href="#">Another action</a></li>
<li><a href="#">Something else here</a></li>
<li class="divider" role="separator"></li>
<li><a href="#">Separated link</a></li>
<li class="divider" role="separator"></li>
<li><a href="#">One more separated link</a></li>
</ul>
</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li><a class="ion-ios-heart" href="#"></a></li>
<li class="dropdown"><a class="dropdown-toggle" href="#" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"><span class="ion-android-search"></span><span> Search</span></a>
<ul class="dropdown-menu">
<li><a href="#">Action</a></li>
<li><a href="#">Another action</a></li>
<li><a href="#">Something else here</a></li>
<li class="divider" role="separator"></li>
<li><a href="#">Separated link</a></li>
</ul>
</li>
</ul>
</div>
<!-- /.navbar-collapse-->
</div>
<!-- /.container-fluid-->
</nav>
<div class="jumbotron">
<div class="align pull-reset">
<div class="col-md-4 col-sm-6 row">
<div class="panel">
<div class="panel-heading">
<h2>Scroll down</h2>
</div>
<div class="panel-body">
<p>keep your eyes on the navbar.</p>
<sup>Cross origin images do not work</sup>
</div>
<div class="panel-footer clearfix">
<button class="pull-right btn btn-default" type="button">Okay</button>
</div>
</div>
</div>
</div>
</div>
<div class="container-fluid">
<div class="col-md-10">
<h1 class="hr">Heading h1</h1>
<p class="psudo-col-2 text-light">
Lorem ipsum dolor sit amet, sea nibh quaestio repudiare an, eos et homero constituto. An quot adhuc mei, consul inimicus honestatis mel ut. Has veri erat intellegebat in. Usu agam magna nonumes eu, id mea dolore feugait cotidieque. In pro duis utamur fabulas, ei suas deserunt atomorum mei. Has eu percipit evertitur. Eam falli mollis ad. Praesent cotidieque usu in, pro quidam omnium gubergren et, recusabo persequeris an has. Duo te ipsum deleniti consulatu, ei nulla oporteat ius, eu est definiebas efficiendi. Nam ad solum suavitate expetendis, pri eu sint assueverit eloquentiam. No eripuit molestie est, nam falli audire electram te.</p>
</div>
<div class="col-md-2">
<aside>
<button class="pull-right btn btn-default" type="button">Bootstrap</button>
</aside>
</div>
<div class="col-md-10">
<h2 class="hr">Heading h2</h2>
<button class="btn btn-default" type="button">Bootstrap</button>
</div>
</div>
<!--.composite-->
body {
font-size: 1rem;
}
nav.navbar {
font-size: 1.4em;
}
[class^='ion-'] {
font-size: 1em;
}
p {
font-size: 1.7em;
line-height: 1.6;
}
p.text-light {
color: #d5d1d7;
}
.jumbotron {
padding-left: 45px;
padding-right: 45px;
}
.jumbotron h1,
.jumbotron h2,
.jumbotron h3,
.jumbotron h4,
.jumbotron h5 {
font-weight: 100;
font-size: 4.8em;
}
h1.hr,
h2.hr,
h3.hr,
h4.hr,
h5.hr {
position: relative;
overflow-x: hidden;
font-wieght: 300;
color: #e2e2e2;
position: relative;
font-family: 'Lato', sans-serif;
font-weight: 100;
display: table;
white-space: nowrap;
}
h1.hr:after,
h2.hr:after,
h3.hr:after,
h4.hr:after,
h5.hr:after {
content: "";
border-bottom: #717171 0.06em solid;
width: 0%;
display: table-cell;
width: 100%;
padding-left: 20px;
position: relative;
left: 10px;
}
.btn.btn-default {
border-radius: 0;
font-size: 1.5rem;
font-weight: 600;
line-height: 3.688rem;
padding: 0 2.875rem;
border: 0;
background-color: #288edf;
box-shadow: inset 0 1px rgba(255,255,255,0.36);
color: #fff;
font-weight: 500;
text-shadow: 0 -1px rgba(0,0,0,0.36);
}
.btn.btn-default:active {
background-color: #1e7dc8;
box-shadow: inset 0 1px rgba(0,0,0,0.12);
color: #fafafa;
}
nav.navbar {
border: 0;
background-color: rgba(255,255,255,0);
height: 64px;
border-radius: 0;
}
nav.navbar.navbar-fixed-top {
display: table;
width: 100%;
}
nav.navbar.navbar-fixed-top [class^='container'] {
display: table-cell;
vertical-align: middle;
min-height: 55px;
}
.navbar-flush {
margin-bottom: 0;
}
body {
background-color: #444;
}
.jumbotron .align {
display: table-cell;
vertical-align: middle;
}
[class^='panel'] {
border-radius: 0;
}
[class^='panel'] h1,
[class^='panel'] h2,
[class^='panel'] h3,
[class^='panel'] h4,
[class^='panel'] h5 {
font-size: 3.4em;
color: #444;
}
.panel-footer {
background-color: rgba(255,255,255,0);
border: 0;
}
[class^="psudo-col"] {
-webkit-column-width: auto;
-moz-column-width: auto;
column-width: auto;
-webkit-column-gap: 4em;
-moz-column-gap: 4em;
column-gap: 4em;
margin-top: 2em;
margin-bottom: 4em;
}
.psudo-col-2 {
-webkit-column-count: 1;
-moz-column-count: 1;
column-count: 1;
}
@media screen and (min-width: 321px) {
.psudo-col-2 {
-webkit-column-count: 2;
-moz-column-count: 2;
column-count: 2;
}
}
.psudo-col-3 {
-webkit-column-count: 1;
-moz-column-count: 1;
column-count: 1;
}
@media screen and (min-width: 321px) {
.psudo-col-3 {
-webkit-column-count: 2;
-moz-column-count: 2;
column-count: 2;
}
}
@media screen and (min-width: 768px) {
.psudo-col-3 {
-webkit-column-count: 3;
-moz-column-count: 3;
column-count: 3;
}
}
.pull-reset {
float: none;
}
.container-fluid {
padding-left: 45px;
padding-right: 45px;
}
.jumbotron {
background-image: url('data:image/svg+xml,%3Csvg width="64" height="64" viewBox="0 0 64 64" xmlns="http://www.w3.org/2000/svg"%3E%3Cpath d="M8 16c4.418 0 8-3.582 8-8s-3.582-8-8-8-8 3.582-8 8 3.582 8 8 8zm0-2c3.314 0 6-2.686 6-6s-2.686-6-6-6-6 2.686-6 6 2.686 6 6 6zm33.414-6l5.95-5.95L45.95.636 40 6.586 34.05.636 32.636 2.05 38.586 8l-5.95 5.95 1.414 1.414L40 9.414l5.95 5.95 1.414-1.414L41.414 8zM40 48c4.418 0 8-3.582 8-8s-3.582-8-8-8-8 3.582-8 8 3.582 8 8 8zm0-2c3.314 0 6-2.686 6-6s-2.686-6-6-6-6 2.686-6 6 2.686 6 6 6zM9.414 40l5.95-5.95-1.414-1.414L8 38.586l-5.95-5.95L.636 34.05 6.586 40l-5.95 5.95 1.414 1.414L8 41.414l5.95 5.95 1.414-1.414L9.414 40z" fill="%239C92AC" fill-opacity="0.4" fill-rule="evenodd"/%3E%3C/svg%3E');
background-size: cover;
background-position: left;
display: table;
width: 100%;
height: 536px;
}
.composite {
background-color: #f5f5f5 !important;
background-blend-mode: darken;
//dark background-color: #333 !important;
//dark background-blend-mode: overlay;
transform: translate3d(0,0,0);
width: 400px;
position: fixed;
left: 0px;
right: 0px;
top: 0px;
bottom: 0px;
overflow: hidden;
transition: -webkit-filter 0.3s;
background-image: var(--blur-composite);
background-position-y: var(--blur-composite-position);
background-size: var(--blur-composite-size-x) var(--blur-composite-size-y);
background-attachment: fixed;
backface-visibility: hidden;
background-repeat: no-repeat;
will-change: transform;
border-bottom: 1px solid rgba(255, 255, 255, .5);
}
.composite li,
.composite a {
//dark color: #fff;
color: #5f5f5f;
background: none!important;
}
const { height, width } = document.body.getBoundingClientRect();
const drawBlurFx = async function (width, height) {
document.body.style.setProperty('--blur-composite-clear', "none");
const canvasOut = await html2canvas(document.querySelector('body'), {
height,
width
});
StackBlur.canvasRGBA(canvasOut, 0, 0, (width * window.devicePixelRatio), (height * window.devicePixelRatio), 8);
document.body.style.setProperty('--blur-composite', `url('${canvasOut.toDataURL("image/jpeg")}')`);
}
drawBlurFx(width, height)
function setPosition () {
document.body.style.setProperty('--blur-composite-position', `-${window.scrollY}px`);
}
window.addEventListener('scroll', setPosition);
const setSizeVars = ({height, width}) => {
document.body.style.setProperty('--blur-composite-size-x', `${width}px`)
document.body.style.setProperty('--blur-composite-size-y', `${height}px`)
}
function tmpClearBlurFx() {
document.body.style.setProperty('--blur-composite-clear', "blur(4px)");
}
function setCompositeSize(e) {
const height = document.body.clientHeight;
const width = document.body.clientWidth;
let resizeTimer;
if (e && e.type === 'resize') {
// During resize
tmpClearBlurFx();
// After resize
clearTimeout(resizeTimer);
resizeTimer = setTimeout(() => {
setSizeVars({
height,
width
});
drawBlurFx(width, height);
});
} else {
setSizeVars({
height,
width
});
}
}
setCompositeSize();
window.addEventListener('resize', setCompositeSize);
Also see: Tab Triggers