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.
.parallax
.mountains
.peak.p0
img(src="https://res.cloudinary.com/nathanj-me/image/upload/v1424406215/mountain-0.svg" alt="mountain peak")
.peak.p1
img(src="https://res.cloudinary.com/nathanj-me/image/upload/v1424406215/mountain-1.svg " alt="mountain peak")
.peak.p2
img(src="https://res.cloudinary.com/nathanj-me/image/upload/v1424406215/mountain-2.svg " alt="mountain peak")
.peak.p3
img(src="https://res.cloudinary.com/nathanj-me/image/upload/v1424406215/mountain-3.svg " alt="mountain peak")
.peak.p4
img(src="https://res.cloudinary.com/nathanj-me/image/upload/v1424406215/mountain-4.svg " alt="mountain peak")
.peak.p5
img(src="https://res.cloudinary.com/nathanj-me/image/upload/v1424406215/mountain-5.svg " alt="mountain peak")
.peak.p6
img(src="https://res.cloudinary.com/nathanj-me/image/upload/v1424406215/mountain-6.svg " alt="mountain peak")
.peak.p7
img(src="https://res.cloudinary.com/nathanj-me/image/upload/v1424406215/mountain-7.svg " alt="mountain peak")
.peak.p8
img(src="https://res.cloudinary.com/nathanj-me/image/upload/v1424406215/mountain-8.svg " alt="mountain peak")
.peak.p9
img(src="https://res.cloudinary.com/nathanj-me/image/upload/v1424406215/mountain-9.svg " alt="mountain peak")
.peak
.overlay
.logo
h1 SCROLL
main
article(title="Lorem")
h1 LOREM
p This effect is achieved with pure CSS. See #[a(target="_blank" href="https://keithclark.co.uk/articles/pure-css-parallax-websites/") this article] for the technique.
p Single-origin coffee gastropub kale chips leggings try-hard. Roof party Brooklyn fap, bicycle rights organic disrupt food truck. Cred mustache chillwave selvage Banksy. Slow-carb artisan skateboard Thundercats, next level Brooklyn fixie. Forage photo booth sustainable 3 wolf moon, quinoa Bushwick direct trade viral gentrify cronut listicle ethical. Post-ironic readymade sriracha, drinking vinegar aesthetic gastropub messenger bag. Retro Echo Park meditation, ennui Kickstarter paleo fashion axe. Hashtag cardigan scenester distillery Banksy, lumbersexual gastropub. Pickled tousled retro, umami food truck biodiesel Austin. Hoodie Truffaut four dollar toast banh mi, artisan master cleanse narwhal flexitarian. Bespoke direct trade Williamsburg umami, paleo Carles synth. Mlkshk bitters scenester, mumblecore direct trade narwhal hella sriracha cliche leggings twee paleo wayfarers. American Apparel locavore street art, actually Carles trust fund ethical. Beard meh organic, try-hard pickled sriracha +1 small batch narwhal hella cornhole chambray synth drinking vinegar.
p Drinking vinegar quinoa fixie aesthetic organic, kale chips literally master cleanse Neutra Helvetica cardigan. Pickled brunch literally vegan viral 8-bit. Art party kogi gluten-free fingerstache, DIY pork belly put a bird on it hashtag 3 wolf moon tote bag chia. PBR&B Tumblr Austin, Odd Future XOXO vegan flexitarian keytar gastropub beard mumblecore skateboard lomo bespoke. Echo Park skateboard beard, migas farm-to-table Helvetica salvia. Cronut blog Truffaut, YOLO umami letterpress wayfarers church-key lo-fi. Ethical whatever banh mi tilde.
p Cronut lomo migas, Bushwick leggings Neutra 3 wolf moon scenester Kickstarter raw denim lo-fi cred tousled photo booth Truffaut. Fashion axe pug quinoa biodiesel stumptown, dreamcatcher bespoke McSweeney's Thundercats crucifix fingerstache keytar chambray cold-pressed. Quinoa tote bag letterpress, kale chips salvia Etsy Truffaut normcore twee butcher chia irony. Keytar wolf scenester, mixtape master cleanse Blue Bottle lomo leggings polaroid Carles stumptown fixie occupy fingerstache cardigan. Gastropub narwhal cred yr. Vice Brooklyn PBR street art Thundercats, VHS typewriter XOXO banh mi mustache normcore asymmetrical salvia viral kitsch. Umami trust fund paleo lumbersexual, scenester Schlitz cold-pressed sartorial artisan Williamsburg migas.
p Single-origin coffee gastropub kale chips leggings try-hard. Roof party Brooklyn fap, bicycle rights organic disrupt food truck. Cred mustache chillwave selvage Banksy. Slow-carb artisan skateboard Thundercats, next level Brooklyn fixie. Forage photo booth sustainable 3 wolf moon, quinoa Bushwick direct trade viral gentrify cronut listicle ethical. Post-ironic readymade sriracha, drinking vinegar aesthetic gastropub messenger bag. Retro Echo Park meditation, ennui Kickstarter paleo fashion axe. Hashtag cardigan scenester distillery Banksy, lumbersexual gastropub. Pickled tousled retro, umami food truck biodiesel Austin. Hoodie Truffaut four dollar toast banh mi, artisan master cleanse narwhal flexitarian. Bespoke direct trade Williamsburg umami, paleo Carles synth. Mlkshk bitters scenester, mumblecore direct trade narwhal hella sriracha cliche leggings twee paleo wayfarers. American Apparel locavore street art, actually Carles trust fund ethical. Beard meh organic, try-hard pickled sriracha +1 small batch narwhal hella cornhole chambray synth drinking vinegar.
p Drinking vinegar quinoa fixie aesthetic organic, kale chips literally master cleanse Neutra Helvetica cardigan. Pickled brunch literally vegan viral 8-bit. Art party kogi gluten-free fingerstache, DIY pork belly put a bird on it hashtag 3 wolf moon tote bag chia. PBR&B Tumblr Austin, Odd Future XOXO vegan flexitarian keytar gastropub beard mumblecore skateboard lomo bespoke. Echo Park skateboard beard, migas farm-to-table Helvetica salvia. Cronut blog Truffaut, YOLO umami letterpress wayfarers church-key lo-fi. Ethical whatever banh mi tilde.
@import url('https://fonts.googleapis.com/css?family=Open\+Sans:100,400,700')
black = #333
black30 = rgba(#000, 0.3)
black50 = rgba(#000, 0.5)
white90 = rgba(#fff, 0.9)
lightblue = #83b6c9
blue = #418eab
purple = #7168b5
perspective = 1
pushBack(z)
s = 1 + (z * -1) / perspective
transform translateZ(unit(z, px)) scale(s)
*,
*:before,
*:after
margin 0
padding 0
box-sizing border-box
html
font-family 'Open Sans', helvetica, serif
font-size 16px
body
background white90
a
display inline-block
color white90
text-decoration none
&:hover
background blue
h1
color white90
padding 4rem 0
font-size 4rem
font-weight 700
letter-spacing .4rem
text-align center
h2
padding 0 0 4rem
font-size 4rem
font-weight 700
letter-spacing .4rem
text-align center
color white90
text-shadow 1px 0 2px black30
border-bottom 1px dotted black50
.parallax
position relative
perspective unit(perspective, px)
perspective-origin 50% 100%
width 100vw
height 100vh
overflow-x hidden
overflow-y auto
.mountains
position relative
width 100vw
height 100vh
transform-style preserve-3d
z-index -1
.peak, .logo
position absolute
top 0
right 0
bottom 0
left 0
transform-origin 50% 100%
&.p0
pushBack(-40)
&.p1
pushBack(-25)
&.p2
pushBack(-15)
&.p3
pushBack(-8)
&.p4
pushBack(-5)
&.p5
pushBack(-4)
&.p6
pushBack(-3)
&.p7
pushBack(-2)
&.p8
pushBack(-1)
&.p9
pushBack(-0.5)
img
position absolute
width 110%
height auto
left -5%
bottom -5%
.overlay
position absolute
width 100vw
height 100vh
left 0
top 0
background linear-gradient(purple 0%, blue 50%, lightblue 100%)
opacity 0.7
.multiply
opacity 1
mix-blend-mode overlay
.logo
pushBack(-2)
h1
font-size 10rem
color black
position absolute
width 100vw
bottom 25vw
padding 0
text-shadow 0 50px 20px black30
main
position relative
width 100vw
padding 40px
background lightblue
z-index 2
article
max-width 800px
margin 0 auto
p
color black50
font-size 1.2rem
max-width 800px
line-height 1.6
margin-bottom 20px
text-align justify
// Safari Sniffing for the purpose of using mix-blend-mode
// Not default in chrome / funky in FF
(function() {
function isSafari() {
var userAgent = navigator.userAgent;
return (/Safari/gi).test(userAgent) &&
!(/Chrome/gi).test(userAgent);
}
if(isSafari()) {
var overlay = document.querySelector('.overlay');
overlay.classList.add('multiply');
}
})();
Also see: Tab Triggers