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 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.
<div class="container">
<svg class="jam" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 716 1008">
<defs>
<mask id="jm-mask">
<rect width="100%" height="100%" fill="#fff" x="0" y="0" />
<path transform="translate(-14.18 394)" class="jm" fill="#000" d="M58.032,583.856 C91.884,583.856 120.9,576.602 142.662,557.258 C161.2,540.332 173.29,513.734 173.29,464.568 L173.29,11.596 L70.928,11.596 L70.928,460.538 C70.928,491.166 57.226,501.644 30.628,503.256 C22.568,504.062 13.702,503.256 4.03,503.256 L-1.13686838e-13,503.256 L-1.13686838e-13,578.214 C15.314,581.438 37.882,583.856 58.032,583.856 Z M333.148,442 L333.148,187.304 C333.148,126.854 375.06,84.942 422.614,84.942 C465.332,84.942 490.318,114.764 490.318,163.93 L490.318,442 L592.68,442 L592.68,187.304 C592.68,126.854 629.756,84.942 679.728,84.942 C721.64,84.942 749.85,114.764 749.85,163.93 L749.85,442 L852.212,442 L852.212,150.228 C852.212,57.538 800.628,0.312 712.774,0.312 C659.578,0.312 611.218,25.298 577.366,80.912 L575.754,80.912 C556.41,27.716 515.304,0.312 461.302,0.312 C402.464,0.312 359.746,28.522 332.342,76.882 L329.924,76.882 L329.924,11.596 L230.786,11.596 L230.786,442 L333.148,442 Z"/>
</mask>
</defs>
<g fill="none" fill-rule="evenodd">
<rect class="bg" width="750" height="1008" fill="#DDE1D4" />
<g transform="translate(-14.18 394)">
<path class="a" fill="#00000A" fill-rule="nonzero" d="M221.052,454.284 C287.144,454.284 322.608,430.104 350.818,390.61 L352.43,390.61 C354.848,414.79 360.49,433.328 366.938,443 L490.256,443 L490.256,435.746 C478.972,428.492 474.136,409.954 474.136,376.102 L474.136,156.064 C474.136,98.032 453.18,53.702 408.85,27.91 C379.028,10.178 340.34,2.118 285.532,2.118 C158.184,2.118 98.54,70.628 95.316,143.974 L212.186,143.974 C215.41,110.122 238.784,87.554 287.144,87.554 C330.668,87.554 350.818,108.51 350.818,139.138 C350.818,171.378 319.384,183.468 242.814,193.946 C149.318,205.23 74.36,229.41 74.36,324.518 C74.36,409.148 136.422,454.284 221.052,454.284 Z M260.546,371.266 C225.888,371.266 197.678,357.564 197.678,320.488 C197.678,283.412 224.276,269.71 279.89,257.62 L282.058274,257.123918 C309.499504,250.838154 335.979333,244.434667 354.042,233.44 L354.042,289.054 C354.042,335.802 316.966,371.266 260.546,371.266 Z"/>
</g>
<rect class="stage" width="716" height="1020" fill="red" mask="url(#jm-mask)"/>
<rect class="dot" width="102.35" height="105" x="56.75" y="233.14" fill="#DDE1D4"/>
</g>
</svg>
<div class="content">
<div class="intro">
<h1 class="band"><span>47 promotions presents</span><span>the jam</span></h1>
<p class="date"><span>friday / july 15, 1977</span><span>from 9:00 pm to 1:00am</span></p>
<p class="location"><span>at clouds disco</span><span>west tollcross, edinburgh</span></p>
</div>
<p class="guests"><span>with special guests</span><span>the rezillos & the jolt / £1.50</span></p>
</div>
</div>
html {
box-sizing: border-box;
}
*, *:before, *:after {
box-sizing: inherit;
}
html, body {
width: 100%;
height: 100%;
}
body {
display: flex;
align-items: center;
justify-content: center;
background-color: black;
color: black;
font-family: neue-haas-grotesk-display, "Helvetica Neue", Helvetica, sans-serif;
font-weight: 600;
font-style: normal;
font-size: 21px;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
font-display: block;
}
.container {
position: relative;
width: 716px;
height: 1008px;
visibility: hidden;
background: red;
cursor: pointer;
// overflow: hidden;
}
.jam {
position: absolute;
z-index: 0;
top: 0;
left: 0;
width: 716px;
height: 1008;
fill: red;
}
.content {
position: relative;
z-index: 2;
width: 716px;
height: 100%;
text-align: right;
padding: 82px 40px;
p {
margin: 0 0 48px;
letter-spacing: 0.5px;
line-height: 1.3;
}
span {
display: block;
}
}
.band {
color: black;
font-family: neue-haas-grotesk-display, "Helvetica Neue", Helvetica, sans-serif;
font-size: 21px;
font-weight: 600;
margin: 0 0 51px;
letter-spacing: 0.5px;
line-height: 1.3;
}
.guests {
align-self: flex-end;
position: absolute;
right: 40px;
bottom: 24px;
}
console.clear();
select = e => document.querySelector(e);
selectAll = e => document.querySelectorAll(e);
const container = select('.container');
const jamTime = 6;
const jamDist = 700;
let master = gsap.timeline({ delay: 1 });
function animateJam() {
let tl = gsap.timeline({
defaults: {
duration: jamTime,
ease: "power4"
},
repeat: -1
});
tl.from('.a', {
x: jamDist*1
})
.from('.jm', {
x: -jamDist*1.5
}, 0)
.from('.dot', {
x: -jamDist/1.4
}, 0)
.to('.a', {
x: -jamDist*2,
ease: "power4.in"
}, jamTime)
.to('.jm', {
x: jamDist*2,
ease: "power4.in"
}, jamTime)
.to('.dot', {
x: jamDist*1.1,
ease: "power4.in"
}, jamTime)
return tl;
}
function animateText() {
let tl = gsap.from('span', {
x: -100,
opacity: 0,
stagger: 0.1,
duration: 4,
ease: "power4"
})
return tl;
}
function init() {
resize();
gsap.set(container, { autoAlpha: 1 });
master.add(animateJam()).add(animateText(), 0);
container.onclick = () => {
console.log('click');
master.restart();
}
}
function resize() {
let vh = window.innerHeight;
// let sh = container.offsetHeight;
let sh = 1008;
let scaleFactor = vh/sh;
if(scaleFactor<1) {
gsap.set(container, { scale: scaleFactor });
}
else {
gsap.set(container, { scale: 1 });
}
}
window.onresize = resize;
window.onload = () => {
init();
};
Also see: Tab Triggers