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.
-
var content = [
{ title: `Let's Get to Know One Another`, image: 'https://images.unsplash.com/photo-1597487389339-5591e52de66f?crop=entropy&cs=tinysrgb&fit=max&fm=jpg&ixid=MXwxNDU4OXwwfDF8cmFuZG9tfHx8fHx8fHw&ixlib=rb-1.2.1&q=80&w=1200'},
{ title: `Some Stuff I Need to Get Off My Chest`, image: 'https://images.unsplash.com/photo-1597201424013-0e06a7018fbd?crop=entropy&cs=tinysrgb&fit=max&fm=jpg&ixid=MXwxNDU4OXwwfDF8cmFuZG9tfHx8fHx8fHw&ixlib=rb-1.2.1&q=80&w=1200'},
{ title: `Call Me, Maybe`, image: 'https://images.unsplash.com/photo-1543408458-baf63378be13?crop=entropy&cs=tinysrgb&fit=max&fm=jpg&ixid=MXwxNDU4OXwwfDF8cmFuZG9tfHx8fHx8fHw&ixlib=rb-1.2.1&q=80&w=1200'}
];
header.header
h1.page-title CSS position sticky parallax effect
main.main
each item in content
section.section
figure.image-container
img(src=item.image alt="")
article.content
h2.section-title= item.title
span.byline Content provided by <a href="https://laurenhallden.com/datingipsum/" target="_blank" rel="noreferrer">the online dating ipsum generator →</a>
p If I make fun of you it's because I like you someone to provide for you documentary filmmaker everything destructive that I do. But I only smoke when drinking Think about it! heyyy I despise you should message me, my last partner told me really only soft drugs friendzone looking for a third if you dress up like a pin-up doll for me. Full-contact Ayn Rand Libertarian full-contact full-contact wildly attractive doesn't hurt.
p P90X you should be clean and intelligent but I only smoke when drinking that means I am wonderful. MFA I love the smell of The Game I am currently addicted to shooting, lol making others feel good very successsful entrepreneur I'm a big fan of I starred in my own reality show. Bald is sexy P90X beekeeping I am currently addicted to I don't really keep a budget I did a lot of modeling work in the mid-80s.
p No robots posing as real people P90X you need a real man working on my screenplay. That just proves my point clubbing I will love you forever shooting laughing hysterically, females performance art or so I've been told there's no such thing as a typical Friday night I'm a nice guy. I am extremely experienced and talented Juggalo with lots of self-respect you need a real man it depends on the night dive bars.
p That's what she said heyyy everything destructive that I do my lizard tongue. Complete lack of shame unworthy of serious consideration if you like I know shirtless pics are a no-no, but beekeeping, unworthy of serious consideration I know shirtless pics are a no-no, but my last partner told me well-built Think about it!. I don't really keep a budget I did a lot of modeling work in the mid-80s well-built I am oddly aroused by for real though unworthy of serious consideration.
p There's no such thing as a typical Friday night I starred in my own reality show I enjoy I'm a big fan of. See, I told you if I make fun of you it's because I like you dive bars because I am a paradox my deep, manly voice, complete lack of shame if you have an innie belly button with lots of self-respect years ago I discovered living on sailboats. Motorcycle collection when I get drunk I am extremely experienced and talented working on my screenplay everything destructive that I do blackjack.
p If that paragraph above turned you off I did a lot of modeling work in the mid-80s it's huge females. I am oddly aroused by documentary filmmaker you could say I'm old-fashioned I have an IQ of 140, which means there's no such thing as a typical Friday night, I am currently addicted to for real though most cats eventually love me I'm a nice guy Juggalo. I hope there are good girls left P90X I do well dating living on sailboats I hope there are good girls left I grow a creepy mustache every February.
footer.footer Fin.
@import url('https://fonts.googleapis.com/css2?family=Lato&family=Playfair+Display:wght@700&display=swap');
:root {
--scale: 0.1;
--space: 8vmin;
--font-primary: 'Lato', sans-serif;
--font-heading: 'Playfair Display', serif;
}
@media (prefers-reduced-motion) {
:root {
--scale: 0;
}
}
* {
box-sizing: border-box;
}
body {
color: hsl(0, 0%, 95%);
background-color: hsl(5, 15%, 5%);
font-size: clamp(1.2rem, 5vw, 1.5rem);
font-family: var(--font-primary);
line-height: 1.6;
}
a {
color: hsl(65, 80%, 60%);
text-decoration: none;
}
a:hover,
a:focus {
text-decoration: underline;
}
.page-title {
text-align: center;
}
.page-title::after {
content: '↓';
display: block;
font-size: 2em;
opacity: 0;
transform: translateY(-24px);
animation: fadein 800ms 500ms cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}
.header,
.footer {
display: grid;
place-items: center;
height: 100vh;
}
.section {
transform-origin: center top;
transform: scaleY(calc(1 - var(--scale)));
}
.section > * {
transform-origin: center top;
transform: scaleY(calc(1 / (1 - var(--scale))));
}
.section-title {
font-family: var(--font-heading);
font-size: clamp(2.5rem, 6vw, 4.5rem);
font-weight: bold;
line-height: 1.125;
}
.byline {
display: block;
font-size: 0.6em;
margin: calc(var(--space) / 1.35) 0;
}
.content {
position: relative;
margin: -50vh auto 0;
padding: var(--space);
max-width: 55ch;
width: calc(100% - var(--space));
background: hsla(5, 15%, 5%, 0.9);
}
.content > * + * {
margin-top: 2rem;
}
.image-container {
position: sticky;
top: 0;
width: 100vw;
height: 100vh;
z-index: -2;
}
.image-container img {
display: block;
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
object-fit: cover;
}
.image-container::after {
content: '';
position: absolute;
bottom: 0;
left: 0;
width: 100%;
height: 50%;
background: linear-gradient(
to bottom,
hsla(5, 15%, 5%, 0) 0%,
hsla(5, 15%, 5%, 0.013) 8.1%,
hsla(5, 15%, 5%, 0.049) 15.5%,
hsla(5, 15%, 5%, 0.104) 22.5%,
hsla(5, 15%, 5%, 0.175) 29%,
hsla(5, 15%, 5%, 0.259) 35.3%,
hsla(5, 15%, 5%, 0.352) 41.2%,
hsla(5, 15%, 5%, 0.45) 47.1%,
hsla(5, 15%, 5%, 0.55) 52.9%,
hsla(5, 15%, 5%, 0.648) 58.8%,
hsla(5, 15%, 5%, 0.741) 64.7%,
hsla(5, 15%, 5%, 0.825) 71%,
hsla(5, 15%, 5%, 0.896) 77.5%,
hsla(5, 15%, 5%, 0.951) 84.5%,
hsla(5, 15%, 5%, 0.987) 91.9%,
hsl(5, 15%, 5%) 100%
);
}
@keyframes fadein {
to {
opacity: 1;
transform: translateY(0);
}
}
Also see: Tab Triggers