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="overflow">
<section class="panels">
<article class="panels__side panels__side--left">
<div class="panels__side panels__side--inner-left">
<p>"Changes and progress very rarely are gifts from above. They come out of struggles from below."</p>
</div>
<div class="panels__side panels__side--inner">
<h1 class="panels__headline">Noam Chomsky</h1>
<svg class="arrow arrow--left" width="40" height="40" viewBox="0 0 24 24"><path d="M0 0h24v24h-24z" fill="none"/><path d="M20 11h-12.17l5.59-5.59-1.42-1.41-8 8 8 8 1.41-1.41-5.58-5.59h12.17v-2z"/></svg>
</div>
</article>
<article class="panels__side panels__side--right">
<div class="panels__side panels__side--inner">
<h1 class="panels__headline">Buzz Aldrin</h1>
<svg class="arrow arrow--right" width="40" height="40" viewBox="0 0 24 24"><path d="M0 0h24v24h-24z" fill="none"/><path d="M12 4l-1.41 1.41 5.58 5.59h-12.17v2h12.17l-5.58 5.59 1.41 1.41 8-8z"/></svg>
</div>
<div class="panels__side panels__side--inner-right">
<p>"The biggest benefit of Apollo was the inspiration it gave to a growing generation to get into science and aerospace."</p>
</div>
</article>
</section>
</div>
<!-- Ettrics -->
<a href="http://ettrics.com/code/dual-sliding-panels/" class="logo" target="_blank">
<img class="logo" src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/45226/ettrics-logo.svg" alt="" />
</a>
// utils
yellow = #F4D03F
blue = #19B5FE
easeout()
transition: all .5s cubic-bezier(0.23, 1, 0.32, 1)
align()
display: flex
align-items: center
justify-content: center
cover()
position: absolute
top: 0
left: 0
width: 100%
height: 100%
// base
*
box-sizing: border-box
-webkit-tap-highlight-color: rgba(255, 255, 255, 0); // remove tap highlight on android chrome
body
font-family: 'Montserrat'
line-height: 1.5
-webkit-font-smoothing: antialiased
// component
.overflow
height: 100vh
overflow: hidden
.panels
width: 200%
&__side
float: left
width: 50%
perspective: 400px
align()
easeout()
&--left,
&--right
will-change: transform
position: relative
left: -25%
transform: translate(0, 0)
&--left
background: yellow
&:hover
.arrow
transform: translate(-100%, -50%)
&--right
background: blue
&:hover
.arrow
transform: translate(0, -50%)
&--left-active
transform: translate(50%, 0)
.panels__side--inner-left
transform: rotateY(0)
.arrow
transform: translate(-50%, -50%) rotate(180deg) !important
&--right-active
transform: translate(-50%, 0)
.panels__side--inner-right
transform: rotateY(0)
.arrow
transform: translate(-50%, -50%) rotate(180deg) !important
&--left-hidden
transform: translate(-50%, 0)
&--right-hidden
transform: translate(50%, 0)
&--inner
cursor: pointer
&--inner-left,
&--inner-right,
&--inner
will-change: transform
padding: 0 5vw
height: 100vh
&--inner-left
transform-origin: right center
transform: rotateY(-90deg)
transition-delay: .1s
background: url('//unsplash.it/1330/900') center/cover
&:before
content: ""
cover()
background: yellow
z-index: -1
opacity: 0.85
&--inner-right
transform-origin: left center
transform: rotateY(90deg)
transition-delay: .1s
background: url('//unsplash.it/1250/900') center/cover
&:before
content: ""
cover()
background: blue
z-index: -1
opacity: 0.85
&__headline
margin: 0
font-size: 40px
text-align: center
color: lighten(black, 10)
p
font-size: 30px
margin: 0
@media (max-width: 640px)
width: 100%
height: 200vh
&__side
float: none
width: 100%
height: 100vh
display: block
text-align: center
&--left,
&--right
top: -25%
left: 0
&--left
&:hover
.arrow
transform: translate(-50%, -80%) rotate(90deg)
&--right
&:hover
.arrow
transform: translate(-50%, -20%) rotate(90deg)
&--left-active
transform: translate(0, 50%)
.panels__side--inner-left
transform: rotateX(0)
.arrow
transform: translate(-50%, -50%) rotate(-90deg) !important
&--right-active
transform: translate(0, -50%)
.panels__side--inner-right
transform: rotateX(0)
.arrow
transform: translate(-50%, -50%) rotate(-90deg) !important
&--left-hidden
transform: translate(0, -50%)
&--right-hidden
transform: translate(0, 50%)
&--inner-left,
&--inner-right,
&--inner
height: 50vh
padding: 2vh 8vw
align()
&--inner-left
transform-origin: center bottom
transform: rotateX(90deg)
&--inner-right
transform-origin: center top
transform: rotateX(-90deg)
&__headline
font-size: 32px
p
font-size: 20px
.arrow
position: absolute
top: 75%
left: 50%
transform: translate(-50%,-50%)
fill: lighten(black, 10)
border: 3px solid lighten(black, 10)
border-radius: 50%
easeout()
@media (max-width: 640px)
transform: translate(-50%, -50%) rotate(90deg)
&--left
top: 25%
.logo
position: fixed
bottom: 3vh
right: 3vw
z-index: 2
img
width: 45px
transform: rotate(0)
easeout()
&:hover
transform: rotate(180deg) scale(1.1)
var Panels = (function() {
var panelLeft = document.querySelector('.panels__side--left');
var panelRight = document.querySelector('.panels__side--right');
var openLeft = function() {
panelLeft.classList.toggle('panels__side--left-active');
panelRight.classList.toggle('panels__side--right-hidden');
};
var openRight = function() {
panelRight.classList.toggle('panels__side--right-active');
panelLeft.classList.toggle('panels__side--left-hidden');
};
var bindActions = function() {
panelLeft.addEventListener('click', openLeft, false);
panelRight.addEventListener('click', openRight, false);
};
var init = function() {
bindActions();
};
return {
init: init
};
}());
Panels.init();
Also see: Tab Triggers