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 URL's 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 it's URL and the proper URL extention.
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 Skypack, which makes packages from npm not only available on a CDN, but prepares them for native JavaScript ES6 import
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.
<a href="https://youtu.be/edSVBJGFPrU" target="_blank" data-keyframers-credit style="color: #FFF"></a>
<script src="https://codepen.io/shshaw/pen/QmZYMG.js"></script>
<div id="app">
<div class="ui-left ui-images">
<div class="ui-layer ui-image -current">
<img src="https://picsum.photos/g/550/1000?image=1081"/>
</div>
<div class="ui-layer ui-image">
<img src="https://picsum.photos/g/550/1000?image=1075"/>
</div>
<div class="ui-layer ui-image">
<img src="https://picsum.photos/g/550/1000?image=1076"/>
</div>
<div class="ui-layer ui-image">
<img src="https://picsum.photos/g/550/1000?image=1048"/>
</div>
<div class="ui-layer ui-image">
<img src="https://picsum.photos/g/550/1000?image=1031"/>
</div>
</div>
<div class="ui-right">
<article class="ui-layer -current">
<div class="ui-header">
<h2 class="ui-heading">Animated.</h2>
</div>
<div class="ui-content"><p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ipsum doloremque expedita odit sint consequatur repellendus nostrum nisi? Quam magnam sed esse dolorem suscipit enim, quod facilis hic dignissimos ea eveniet.</div>
</article>
<article class="ui-layer">
<div class="ui-header"><h2 class="ui-heading">Movement.</h2></div>
<div class="ui-content"><p>Lorem ipsum dolor sit amet consectetur, adipisicing elit. Quisquam ducimus tempore maiores iusto alias quam veniam! Cum ipsa, rem voluptates explicabo iusto nulla. Iste quasi dignissimos reiciendis blanditiis quas recusandae?</p></div>
</article>
<article class="ui-layer">
<div class="ui-header"><h2 class="ui-heading">Keyframes.</h2></div>
<div class="ui-content"><p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Soluta omnis incidunt sapiente pariatur, vero nam necessitatibus expedita dolore non eius eos nesciunt facilis in ratione harum earum, voluptates eum quibusdam?</p></div>
</article>
<article class="ui-layer">
<div class="ui-header"><h2 class="ui-heading">Easing.</h2></div>
<div class="ui-content"><p>Lorem ipsum, dolor sit amet consectetur adipisicing elit. Id ipsum a cumque deserunt ut enim nostrum libero voluptates debitis consequuntur nam provident possimus expedita cum numquam, architecto corrupti eaque officia!</p></div>
</article>
<article class="ui-layer">
<div class="ui-header"><h2 class="ui-heading">Timing.</h2></div>
<div class="ui-content"><p>Lorem ipsum, dolor sit amet consectetur adipisicing elit. Labore quos aliquam incidunt minus provident tempora, nesciunt deserunt. Libero voluptatibus ea corporis consectetur laborum quisquam. Architecto, placeat voluptas? Itaque, commodi. Voluptate!</p></div>
</article>
</div>
<div class="ui-sidebar">
<div class="ui-button" role="button">
</div>
</div>
<div class="ui-controls">
<button class="ui-nav-back" title="Back"></button>
<button class="ui-nav-forward" title="Forward"></button>
</div>
<div class="ui-menu">
<div class="ui-left">
<div class="ui-header"></div>
<div class="ui-section">
<div class="ui-heading">Passionate.</div>
<ul class="ui-list">
<li class="ui-item">Something</li>
<li class="ui-item">Something Else</li>
<li class="ui-item">Yet Another Thing</li>
<li class="ui-item">Something Different</li>
<li class="ui-item">Thing</li>
</ul>
</div>
<div class="ui-section">
<div class="ui-heading">Services</div>
<ul class="ui-list">
<li class="ui-item">Something</li>
<li class="ui-item">Something Else</li>
<li class="ui-item">Yet Another Thing</li>
<li class="ui-item">Something Different</li>
<li class="ui-item">Thing</li>
</ul>
</div>
<div class="ui-section">
<div class="ui-heading">Services</div>
<ul class="ui-list">
<li class="ui-item">Something</li>
<li class="ui-item">Something Else</li>
<li class="ui-item">Yet Another Thing</li>
<li class="ui-item">Something Different</li>
<li class="ui-item">Thing</li>
</ul>
</div>
<div class="ui-section">
<div class="ui-heading">Services</div>
<ul class="ui-list">
<li class="ui-item">Something</li>
<li class="ui-item">Something Else</li>
<li class="ui-item">Yet Another Thing</li>
<li class="ui-item">Something Different</li>
<li class="ui-item">Thing</li>
</ul>
</div>
</div>
<div class="ui-right">
<div class="ui-headings">
<h2 class="ui-heading">Passionate.</h2>
<h2 class="ui-heading">Enduring.</h2>
<h2 class="ui-heading">Attractive.</h2>
<h2 class="ui-heading">Creatine.</h2>
<h2 class="ui-heading">Agile.</h2>
</div>
</div>
</div>
</div>
$gray: #333B44;
@import url('https://fonts.googleapis.com/css?family=Oswald:200');
// img { max-width: 100%; height: auto; }
#app {
display: grid;
grid-template-columns: 1fr 1fr 10vmin;
height: 90vh;
width: 90vw;
box-shadow: 0 2vmin 6vmin rgba(black, 0.2);
color: white;
overflow: hidden;
}
.ui-layer {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
// .ui-image {
// width: 100%;
// }
.ui-images {
background-color: #fff;
overflow: hidden;
img {
display: block;
margin: 0 -15%;
width: 130%;
height: 100%;
object-fit: cover;
opacity: .6;
filter: contrast(.9);
}
}
.ui-right {
> .ui-layer {
display: grid;
grid-template-columns: 1fr 1.7fr;
}
}
/* ---------------------------------- */
article.ui-layer {
.ui-header {
display: flex;
flex-direction: column;
justify-content: center;
}
.ui-heading {
display: inline-block;
transform: rotate(-90deg);
margin: 0;
text-transform: uppercase;
white-space: nowrap;
}
.ui-content {
display: flex;
flex-direction: column;
justify-content: center;
padding-right: 5vmin;
> p {
font-size: .75rem;
line-height: 1.6;
letter-spacing: 1px;
color: rgba(white, .7);
}
}
}
.ui-sidebar {
grid-column: 3 / -1;
border-left: 1px solid rgba(white, 0.1);
padding: 3vh 0;
display: flex;
flex-direction: column;
align-items: center;
justify-content: flex-start;
}
.ui-button {
height: 5vmin;
width: 5vmin;
z-index: 2;
transform-style: preserve-3d;
perspective: 50px;
cursor: pointer;
&:before, &:after {
content: '';
position: absolute;
height: 1vmin;
width: 100%;
background-color: #fff;
transition-property: transform, transform-origin;
transition-duration: .5s;
transition-timing-function: cubic-bezier(.5, 0, .5, 1);
border-radius: .3vh;
backface-visibility: visible;
}
&:after {
transform-origin: right center;
transform: translateY(200%) rotate(0) scaleX(.8);
}
&.-open {
&:before {
transform: translateY(150%) rotateZ(-45deg) rotateY(180deg);
}
&:after {
transform-origin: center center;
transform: translateY(150%) rotateZ(45deg) rotateY(180deg) scaleX(1);
}
}
}
/* ---------------------------------- */
.ui-menu {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
display: grid;
grid-template-columns: 1fr 1fr 10vmin;
background: rgba($gray, 0.9);
> .ui-left, > .ui-right {
display: grid;
grid-template-rows: 15vh 1fr 15vh;
grid-template-columns: 10vh 1fr;
}
> .ui-left {
padding: 0 5vh;
grid-template-rows: 15vh 1fr 1fr ;
grid-template-columns: repeat(2, 1fr);
> .ui-header {
grid-row: 1 / 2;
grid-column: 1 / -1;
}
}
> .ui-right {
background-color: $gray;
.ui-headings {
grid-row: 2 / 3;
grid-column: 2 / 3;
display: flex;
flex-direction: column;
justify-content: space-between;
}
}
}
.ui-section {
transition: transform .5s cubic-bezier(.5, 0, .5, 1);
.ui-list {
padding: 0;
list-style-type: none;
}
.ui-item {
font-size: .5rem;
line-height: 2;
opacity: .6;
letter-spacing: 1px;
}
}
.ui-heading {
letter-spacing: .3em;
margin: 0;
text-transform: uppercase;
white-space: nowrap;
font-weight: 200;
font-family: 'Oswald', sans-serif;
}
/* ---------------------------------- */
.ui-controls {
position: absolute;
bottom: 0;
right: 0;
}
.ui-nav-back,
.ui-nav-forward {
background: none;
appearance: none;
-webkit-appearance: none;
border: none;
padding: 0;
width: 2em;
height: 2em;
font-size: 2.3vmin;
background: rgba(#FFF,.9);
color: transparent;
display: inline-flex;
transition: background-color .4s linear;
&:before {
content: '>';
display: block;
color: $gray;
font-size: 1.25em;
height: 1.2em;
margin: auto;
font-family: 'Oswald', sans-serif;
font-weight: 200;
}
&:hover {
background: #eee;
}
}
.ui-nav-back:before {
content: '<';
}
/* ---------------------------------- */
$menu-duration: .6s;
.ui-menu {
transition: opacity $menu-duration linear, visibility 0s linear 0s;
.ui-heading .char {
transition: transform .8s cubic-bezier(.5,.0,.2,1), opacity .8s linear;
transform: translateX(0em);
}
&:not(.-visible) {
opacity: 0;
visibility: hidden;
transition-delay: 0s, $menu-duration;
.ui-section {
transform: translateX(50%);
}
.ui-heading .char {
opacity: 0;
transform: translateX(2em);
transform: translateX( calc( 1em + .25em * var(--char-index) ) );
}
}
}
/* ---------------------------------- */
$layer-duration: .6s;
.ui-content { display: block; }
.ui-layer {
transition: opacity $layer-duration linear, visibility 0s linear 0s;
img,
.ui-content,
.ui-heading .char {
transition: transform $layer-duration * 1.5 cubic-bezier(.5,.0,.2,1);
transform: translateX(0em);
}
img {
display: block;
transform: translateX(-10%);
}
&.-current {
> img {
transform: none;
}
~ .ui-layer {
> img {
transform: translateX(10%);
}
}
}
&:not(.-current) {
opacity: 0;
visibility: hidden;
transition-delay: 0s, $layer-duration;
.ui-content,
.ui-heading .char {
transition-duration: $layer-duration;
}
.ui-content {
transform: translateY(2em);
}
.ui-heading .char {
transform: translateX(-1em);
transform: translateX( calc( -1em + (-.25em * var(--char-index) ) ) );
}
}
}
/* ---------------------------------- */
body {
background-image: linear-gradient(to bottom, $gray, #2F363F);
}
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
*, *:before, *:after {
box-sizing: border-box;
position: relative;
}
body, html {
height: 100%;
width: 100%;
margin: 0;
padding: 0;
display: flex;
justify-content: center;
align-items: center;
}
console.clear();
Splitting({
target: '.ui-heading',
by: 'chars'
});
const elMenu = document.querySelector('.ui-menu');
const elButton = document.querySelector('.ui-button');
elButton.addEventListener('click', () => {
elMenu.classList.toggle('-visible');
elButton.classList.toggle('-open');
});
const elArticles = document.querySelectorAll('article.ui-layer');
const articleCount = elArticles.length;
let currentPage = 0;
function navigate(nextPage){
nextPage = ( (nextPage % articleCount) + articleCount ) % articleCount;
if (nextPage === currentPage) {
return;
}
currentPage = nextPage;
document.querySelectorAll(`.-current`)
.forEach(el => el.classList.remove('-current'));
document.querySelectorAll(`article:nth-child(${currentPage + 1}), .ui-image:nth-child(${currentPage + 1})`).forEach(el => el.classList.add('-current'));
}
document.querySelector('.ui-nav-back')
.addEventListener('click', e => {
navigate( currentPage - 1 );
});
document.querySelector('.ui-nav-forward')
.addEventListener('click', e => {
navigate( currentPage + 1 );
});
document.addEventListener('keyup', e => {
switch (e.key) {
case 'ArrowDown':
case 'ArrowRight':
navigate( currentPage + 1 );
break;
case 'ArrowUp':
case 'ArrowLeft':
navigate( currentPage - 1 );
break;
default:
break;
}
});
// elMenu.addEventListener('click', () => {
// elMenu.classList.toggle('-visible');
// });
Also see: Tab Triggers