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.
#wrap
.arrow.right
.arrow.left
.spritebox
-12.times do
.sprite
.spritebody
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" style="display:none">
<defs>
<filter id="squiggly-0">
<feTurbulence id="turbulence" baseFrequency="0.02" numOctaves="3" result="noise" seed="0"/>
<feDisplacementMap id="displacement" in="SourceGraphic" in2="noise" scale="2" />
</filter>
<filter id="squiggly-1">
<feTurbulence id="turbulence" baseFrequency="0.02" numOctaves="3" result="noise" seed="1"/>
<feDisplacementMap in="SourceGraphic" in2="noise" scale="3" />
</filter>
<filter id="squiggly-2">
<feTurbulence id="turbulence" baseFrequency="0.02" numOctaves="3" result="noise" seed="2"/>
<feDisplacementMap in="SourceGraphic" in2="noise" scale="2" />
</filter>
<filter id="squiggly-3">
<feTurbulence id="turbulence" baseFrequency="0.02" numOctaves="3" result="noise" seed="3"/>
<feDisplacementMap in="SourceGraphic" in2="noise" scale="3" />
</filter>
<filter id="squiggly-4">
<feTurbulence id="turbulence" baseFrequency="0.02" numOctaves="3" result="noise" seed="4"/>
<feDisplacementMap in="SourceGraphic" in2="noise" scale="1" />
</filter>
</defs>
</svg>
@font-face {
font-family: Domaine;
src: url(https://s3-us-west-2.amazonaws.com/s.cdpn.io/383755/DomaineDisplayTest-Black.woff);
}
$bl: #219ce8;
$b: darken($bl, 20%);
$g: darken($bl, 30%);
$w: #fff;
$tr: cubic-bezier(1, 0, 0, 1);
$t: transparent;
body {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
width: 100vw;
font-family: "Futura";
overflow: hidden;
background: $bl;
color: $b;
svg {
position: absolute;
z-index: -9999;
}
&:before {
content: "";
position: absolute;
width: 100%;
height: 100%;
background: url("https://s3-us-west-2.amazonaws.com/s.cdpn.io/383755/studio-ghibli.png");
background-size: cover;
background-position: center;
opacity: 0.25;
animation: squiggly-anim 0.3s infinite;
}
* {
box-sizing: border-box;
}
#wrap {
position: relative;
.spritebox {
position: absolute;
width: 100%;
height: 100%;
left: 0;
top: 0;
overflow: hidden;
}
.sprite {
position: absolute;
z-index: 999;
width: 40px;
height: 40px;
top: -20px;
transform: rotate(-90deg);
@keyframes scatter {
from {
offset-distance: 0;
}
to {
offset-distance: 120%;
}
}
@keyframes scatter2 {
from {
offset-distance: 0;
}
to {
offset-distance: 120%;
}
}
&:first-of-type,
&:nth-of-type(5),
&:nth-of-type(10) {
offset-path: path(
"M 40 0 C 75 170 160 140 200 280 Q 220 400 340 400 Q 420 380 480 540 "
);
}
&:nth-of-type(3),
&:nth-of-type(12) {
offset-path: path(
"M 480 0 C 75 170 400 180 240 320 Q 220 400 260 420 Q 340 440 220 540 "
);
transform: rotate(-90deg);
}
&:nth-of-type(4),
&:nth-of-type(11),
&:nth-of-type(2) {
offset-path: path(
"M 420 0 C 480 260 380 380 260 300 Q 200 180 320 160 Q 660 260 280 540 "
);
}
&:nth-of-type(6),
&:nth-of-type(9) {
offset-path: path(
"M 420 0 C 480 260 380 200 160 80 Q 0 20 60 160 Q 200 320 140 540 "
);
}
&:nth-of-type(7),
&:nth-of-type(8) {
offset-path: path(
"M 160 0 C 200 20 360 80 300 140 Q 280 200 140 340 Q 80 400 140 540"
);
}
.spritebody {
width: 100%;
height: 100%;
background: linear-gradient(to right, $t 49%, $g 49%, $g 51%, $t 51%),
linear-gradient(to bottom, $t 49%, $g 49%, $g 51%, $t 51%),
linear-gradient(45deg, $t 49%, $g 49%, $g 51%, $t 51%),
linear-gradient(135deg, $t 49%, $g 49%, $g 51%, $t 51%),
linear-gradient(22.5deg, $t 49%, $g 49%, $g 51%, $t 51%),
linear-gradient(79deg, $t 49%, $g 49%, $g 51%, $t 51%),
linear-gradient(12deg, $t 49%, $g 49%, $g 51%, $t 51%),
linear-gradient(106deg, $t 49%, $g 49%, $g 51%, $t 51%),
linear-gradient(136deg, $t 49%, $g 49%, $g 51%, $t 51%),
linear-gradient(145deg, $t 49%, $g 49%, $g 51%, $t 51%),
linear-gradient(175deg, $t 49%, $g 49%, $g 51%, $t 51%),
linear-gradient(205deg, $t 49%, $g 49%, $g 51%, $t 51%),
linear-gradient(65deg, $t 49%, $g 49%, $g 51%, $t 51%),
radial-gradient(circle at center, $g 50%, $t 60%);
border-radius: 100%;
z-index: -1;
animation: squiggly-anim 0.2s infinite;
}
@for $i from 1 through 5 {
&:nth-of-type(#{$i}) {
&:before,
&:after {
animation-delay: #{$i/4}s;
}
.spritebody {
transform: scale(#{1 - ($i/20)});
}
}
}
@for $i from 6 through 12 {
&:nth-of-type(#{$i}) {
.spritebody {
transform: scale(#{0.3 + ($i/20)});
}
}
}
&:nth-of-type(2n) {
&:after,
&:before {
box-shadow: inset 0px 2px 0 2px $w;
}
}
&:nth-of-type(3n) {
&:after,
&:before {
box-shadow: inset -1px 0px 0 2px $w;
top: 15px;
}
}
&:nth-of-type(4n) {
&:after,
&:before {
box-shadow: inset -1px -2px 0 2px $w;
top: 15px;
}
}
&:after,
&:before {
content: "";
position: absolute;
width: 8px;
height: 10px;
background: $g;
border-radius: 100%;
box-shadow: inset 2px 2px 0 2px $w;
left: 10px;
top: 20px;
animation: backnforth 0.3s ease-in-out infinite alternate;
z-index: 9;
@keyframes backnforth {
from {
transform: translateX(-2.5px);
}
to {
transform: translateX(2.5px);
}
}
}
&:before {
left: 20px;
animation: backnforth2 0.3s ease-in-out infinite alternate;
@keyframes backnforth2 {
from {
transform: scaleX(-1) translateX(2.5px);
}
to {
transform: scaleX(-1) translateX(-2.5px);
}
}
}
}
&:after {
content: "";
position: absolute;
width: 100%;
height: 100%;
top: 0%;
left: 0%;
background: $b;
box-shadow: 0 0 0 3px $b;
z-index: -1;
animation: squiggly-anim 0.3s infinite;
transform: scaleX(0);
transition: 1s $tr;
transition-delay: 1s;
}
&.loaded {
.spritebox {
&.zoomies {
.sprite {
animation: scatter2 1s ease-in-out 1 forwards;
}
}
.sprite {
animation: scatter 2s ease-in-out 1 forwards;
@for $i from 1 through 12 {
&:before,
&:after {
animation-delay: #{0.5/$i}s;
}
&:nth-of-type(#{$i}) {
left: calc(#{($i - 1) * 5.25%} - 150px);
animation-delay: #{2/($i + random(10)) + 0.5}s;
animation-duration: #{6/(random(10)) + 1}s;
}
}
}
}
&:after {
transform: scaleX(1);
}
.arrow {
transform: scale(1);
}
.container {
transform: scaleX(1);
&:before {
transform: scaleX(0);
}
}
}
.arrow {
position: absolute;
z-index: 999;
width: 40px;
height: 40px;
background: $b;
right: -40px;
top: calc(50% - 20px);
cursor: pointer;
transition: transform 0.3s ease-in-out, background 0.3s ease-in-out,
box-shadow 0.3s ease-in-out;
transform: scale(0);
transition-delay: 2s, 0s, 0s;
animation: squiggly-anim 0.3s infinite;
&:nth-of-type(2) {
right: auto;
left: -40px;
&:active {
&:before {
box-shadow: -2px -2px 0 0 $bl;
}
}
&:hover {
&:before {
box-shadow: -2px -2px 0 0 $b;
}
}
&:before {
box-shadow: -2px -2px 0 0 #fff;
left: auto;
right: 5%;
}
}
&:hover {
background: $w;
box-shadow: inset 0 0 0 3px $b;
&:active {
background: $b;
&:before {
box-shadow: 2px 2px 0 0 $bl;
}
}
&:before {
box-shadow: 2px 2px 0 0 $b;
}
}
&:before {
content: "";
position: absolute;
width: 50%;
height: 50%;
top: 25%;
left: 5%;
box-shadow: 2px 2px 0 0 #fff;
transform: rotate(-45deg);
transition: inherit;
}
}
}
.container {
height: 500px;
width: 700px;
overflow: hidden;
position: relative;
box-shadow: 0 30px 30px -20px rgba(0, 0, 0, 0.25);
transition: 0.5s $tr;
transform: scaleX(0);
transform-origin: left;
&:before {
content: "";
position: absolute;
width: 100%;
height: 100%;
z-index: 999;
background: $b;
top: 0;
left: 0;
transition: inherit;
transform-origin: right;
transition-delay: 0.5s;
}
.inner {
position: absolute;
width: 100%;
height: 100%;
left: 0;
top: 0;
transform: translateX(var(--slide));
transition: 0s ease-in-out;
transition-delay: 1.5s;
}
.slide {
position: absolute;
width: 100%;
height: 100%;
left: 0;
top: 0;
padding: 30px;
box-sizing: border-box;
display: flex;
flex-wrap: nowrap;
justify-content: flex-start;
align-items: flex-start;
flex-direction: column-reverse;
background: $bl;
&:before {
content: "";
position: absolute;
width: 100%;
height: 100%;
background: linear-gradient(to bottom, transparent 35%, $bl 75%);
top: 0;
left: 0;
z-index: 1;
}
&:after {
content: "";
position: absolute;
display: block;
width: 100%;
height: 100%;
left: 0;
top: 0;
background: linear-gradient(-135deg, $t 50%, $bl 50%);
opacity: 0.5;
z-index: 1;
}
&.active {
.bg {
opacity: 1;
transform: scale(1.25);
transition: 1.5s ease-in-out;
transition-delay: 2.25s;
}
h3 {
.char {
@for $i from 1 through 4 {
&:nth-of-type(#{$i}) {
transition-delay: #{$i/15 + 2}s;
transform: translateY(0);
}
}
}
}
h1 {
opacity: 1;
.word {
@for $i from 1 through 10 {
&:nth-of-type(#{$i}) {
&:before {
transition-delay: #{$i/10 + 2.4}s;
}
&:after {
animation-delay: #{$i/10 + 2}s;
}
}
}
&:before {
transform: translateY(0);
}
&:after {
animation: scaleIn 0.6s ease-in-out;
animation-delay: 2s;
@keyframes scaleIn {
0% {
transform: scaleX(0);
}
25% {
transform: scaleX(1);
transform-origin: left;
}
75% {
transform: scaleX(1);
transform-origin: right;
}
100% {
transform: scaleX(0);
transform-origin: right;
}
}
}
}
.smallcaps {
.word {
@for $i from 1 through 10 {
&:nth-of-type(#{$i}) {
&:before {
transition-delay: #{$i/12 + 2.6}s;
}
}
}
}
}
}
.content {
transition-delay: 2s;
transform: scaleX(1);
transform-origin: left;
&:before {
transform: scaleX(0);
transition-delay: 2.5s;
transform-origin: right;
}
p {
opacity: 1;
transition-delay: 3s;
}
}
}
.bg {
position: absolute;
width: 100%;
height: 100%;
left: 0;
top: 0;
opacity: 0;
transform: scale(1);
transition: 1.5s ease-in-out;
div {
position: absolute;
width: 100%;
height: 100%;
left: 0;
top: 0;
opacity: 0.5;
background-size: cover;
background-position: center;
filter: saturate(0) contrast(2) brightness(1);
}
&:before,
&:after {
content: "";
position: absolute;
width: 100%;
height: 100%;
left: 0;
top: 0;
background: linear-gradient(-135deg, $w 50%, $bl 50%);
z-index: 2;
mix-blend-mode: multiply;
}
&:after {
background: $bl;
z-index: 1;
mix-blend-mode: soft-light;
}
}
.content {
z-index: 3;
display: inline-block;
width: 100%;
padding: 10px 20px;
position: relative;
transition: transform 0.5s $tr;
transform-origin: right;
transform: scaleX(0);
transition-delay: 0.5s;
&:before,
&:after {
content: "";
position: absolute;
width: calc(100% + 4px);
height: calc(100% + 4px);
top: -2px;
left: -2px;
background: $b;
z-index: 2;
transition: transform 0.5s $tr;
transform-origin: left;
transition-delay: 0s;
animation: squiggly-anim 0.3s infinite;
}
&:after {
background: $w;
transform: scaleX(1);
z-index: -1;
width: 100%;
height: 100%;
left: 0;
top: 0;
}
}
h3 {
position: absolute;
z-index: 99;
color: $w;
font-size: 50px;
top: 10px;
right: 10px;
margin: 0;
mix-blend-mode: overlay;
.char {
display: inline-block;
transform: translateY(-200%) skewY(40deg);
transition: 0.8s $tr;
}
}
h1 {
font-family: "Domaine";
font-size: 80px;
margin: 10px 0 20px;
top: 0px;
left: -5px;
z-index: 0;
color: $t;
max-width: calc(100% + 10px);
transition: 0.3s $tr;
transform: translateX(-30px);
opacity: 1;
font-weight: 900;
padding: 0 30px;
z-index: 9;
opacity: 0;
max-width: 75%;
line-height: 0.85;
transition-delay: 0.6s;
.word {
position: relative;
color: $t;
display: inline-block;
overflow: hidden;
padding: 30px 10px;
margin: -30px -10px;
&:before {
content: attr(data-word);
position: absolute;
color: $w;
transition: 0.3s $tr;
transform: translateY(300%) skewY(-20deg);
transition-delay: 0s;
}
&:after {
content: "";
position: absolute;
width: 100%;
height: 4px;
left: 0;
background: $b;
top: calc(100% - 30px);
transition: 0.3s $tr;
transform-origin: left;
transform: scaleX(0);
transition-delay: 0.3s;
}
}
.smallcaps {
display: block;
font-size: 40px;
margin-left: -10px;
.smallcaps {
display: inline-block;
margin-left: 5px;
}
}
}
p {
position: relative;
z-index: 1;
opacity: 0;
transition: 0.3s ease-in-out;
font-size: 17px;
line-height: 1.5;
padding: 0;
margin: 0;
color: $g;
}
@for $i from 1 through 40 {
&:nth-of-type(#{$i}) {
left: #{($i - 1) * 100%};
}
}
}
}
@keyframes squiggly-anim {
0% {
-webkit-filter: url("#squiggly-0");
filter: url("#squiggly-0");
}
25% {
-webkit-filter: url("#squiggly-1");
filter: url("#squiggly-1");
}
50% {
-webkit-filter: url("#squiggly-2");
}
75% {
-webkit-filter: url("#squiggly-3");
filter: url("#squiggly-3");
}
100% {
-webkit-filter: url("#squiggly-4");
filter: url("#squiggly-4");
}
}
}
const app = document.getElementById("wrap");
var slider = 0;
const container = document.createElement("div");
container.setAttribute("class", "container");
const inner = document.createElement("div");
inner.setAttribute("class", "inner");
app.appendChild(container);
container.appendChild(inner);
var request = new XMLHttpRequest();
request.open("GET", "https://ghibliapi.vercel.app/films", true);
request.onload = function loadFilms() {
// Begin accessing JSON data here
var data = JSON.parse(this.response);
if (request.status >= 200 && request.status < 400) {
data.forEach(movie => {
const slide = document.createElement("div");
const content = document.createElement("div");
const bgimg = document.createElement("div");
const img = document.createElement("div");
var str = movie.title;
str = str.replace(/\s+/g, "-").toLowerCase();
str = str.replace(/'/g, "-");
slide.setAttribute("class", "slide " + str);
content.setAttribute("class", "content");
bgimg.setAttribute("class", "bg");
const h1 = document.createElement("h1");
h1.textContent = movie.title;
const h3 = document.createElement("h3");
h3.textContent = movie.release_date;
h3.setAttribute("data-splitting", "chars");
h1.setAttribute("data-splitting", "words");
const p = document.createElement("p");
movie.description = movie.description.substring(0, 400);
p.textContent = `${movie.description}...`;
inner.appendChild(slide);
slide.appendChild(content);
slide.appendChild(bgimg);
bgimg.appendChild(img);
img.style.backgroundImage =
"url('https://s3-us-west-2.amazonaws.com/s.cdpn.io/383755/" +
str +
".jpg')";
slide.appendChild(h1);
slide.appendChild(h3);
content.appendChild(p);
});
} else {
const errorMessage = document.createElement("marquee");
errorMessage.textContent = `Something is no bueno`;
app.appendChild(errorMessage);
}
$(".right").click(function() {
var total = $(".slide").length;
if (slider < (total - 1) * 100) {
slider = slider + 100;
$(".slide.active")
.next()
.addClass("active");
$(".slide.active")
.first()
.removeClass("active");
} else {
slider = 0;
$(".inner .slide").removeClass("active");
$(".inner .slide")
.first()
.addClass("active");
}
$("body")
.get(0)
.style.setProperty("--slide", "-" + slider + "%");
});
$(".left").click(function() {
var total = $(".slide").length;
if (slider == 0) {
slider = (total - 1) * 100;
$(".slide")
.last()
.addClass("active");
$(".slide")
.first()
.removeClass("active");
} else {
slider = slider - 100;
$(".slide.active")
.prev()
.addClass("active");
$(".slide.active")
.last()
.removeClass("active");
}
$("body")
.get(0)
.style.setProperty("--slide", "-" + slider + "%");
});
};
var smallType = [
"in the",
"of the",
"my ",
"My ",
"the ",
"The ",
"Up on",
"Was "
];
request.send();
$(".arrow").click(function() {
$(".spritebox").toggleClass("zoomies");
});
$(document).ready(function() {
setTimeout(function() {
$.each(smallType, function(index, value) {
$("h1:contains(" + value + ")").html(function(_, html) {
var regex = new RegExp(value, "g");
return html.replace(
regex,
'<span class="smallcaps">' + value + "</span>"
);
});
});
$("#wrap").addClass("loaded");
Splitting();
}, 500);
setTimeout(function() {
$(".inner .slide")
.first()
.addClass("active");
}, 700);
});
Also see: Tab Triggers