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.
<main>
<!-- IMAGE COVERUP COMPONENT -->
<section>
<div class="container-fluid p-0">
<div class="row cmpnt--image-coverup m-0">
<div class="col-12 p-0 all-vh ic__image--one">
<img src="https://picsum.photos/600/800?random=3" width="2250" height="1613" class="img-cover">
<div class="panel-on-image">
<p>Nunc commodo in lectus eu accumsan. Phasellus ac libero eu urna feugiat tempor. Nunc sit amet turpis lacus. Nam ultrices ac dolor quis rhoncus. Aliquam ac porttitor neque.</p>
</div>
</div>
<div class="col-12 p-0 all-vh overflow-hidden ic__image--two">
<img src="https://picsum.photos/600/800?random=4" width="2250" height="1613" class="img-cover">
</div>
</div>
</div>
</section>
<!-- END IMAGE COVERUP COMPONENT -->
<!-- PAGE SPLIT COMPONENT -->
<section>
<div class="container-fluid p-0">
<div class="row cmpnt--page-split">
<div class="col-12 col-lg-7 p-0 all-vh cmpnt--page-split--image">
<img src="https://picsum.photos/600/800?random=5" width="600" height="540" class="ps__image--one" style="">
<img src="https://picsum.photos/600/800?random=6" width="000" height="540" class="ps__image--two" style="">
</div>
<div class="col-12 col-lg-5 all-vh cmpnt--page-split--text">
<div class="vertical-center vh">
<div class="vertical-el">
<p>Nam ac turpis nec nisi suscipit facilisis. Donec ac ligula sed quam pulvinar venenatis in non sem. Nunc pharetra ex non mi tincidunt, sit amet accumsan lacus lacinia. Aliquam in imperdiet orci, eget tristique sapien. Aliquam malesuada vel dolor consequat finibus.</p>
</div>
</div>
</div>
</div>
</div>
</section>
<!-- END PAGE SPLIT COMPONENT 7/5 -->
<!-- IMAGE COVERUP COMPONENT -->
<section>
<div class="container-fluid p-0">
<div class="row cmpnt--image-coverup m-0">
<div class="col-12 p-0 all-vh ic__image--one">
<img src="https://picsum.photos/600/800?random=3" width="2250" height="1613" class="img-cover">
<div class="panel-on-image">
<p>Nunc commodo in lectus eu accumsan. Phasellus ac libero eu urna feugiat tempor. Nunc sit amet turpis lacus. Nam ultrices ac dolor quis rhoncus. Aliquam ac porttitor neque.</p>
</div>
</div>
<div class="col-12 p-0 all-vh overflow-hidden ic__image--two">
<img src="https://picsum.photos/600/800?random=4" width="2250" height="1613" class="img-cover">
</div>
</div>
</div>
</section>
<!-- END IMAGE COVERUP COMPONENT -->
<!-- PAGE SPLIT COMPONENT -->
<section>
<div class="container-fluid p-0">
<div class="row cmpnt--page-split">
<div class="col-12 col-lg-7 p-0 all-vh cmpnt--page-split--image">
<img src="https://picsum.photos/600/800?random=7" width="600" height="540" class="ps__image--one" style="">
<img src="https://picsum.photos/600/800?random=8" width="000" height="540" class="ps__image--two" style="">
</div>
<div class="col-12 col-lg-5 all-vh cmpnt--page-split--text">
<div class="vertical-center vh">
<div class="vertical-el">
<p>Nam ac turpis nec nisi suscipit facilisis. Donec ac ligula sed quam pulvinar venenatis in non sem. Nunc pharetra ex non mi tincidunt, sit amet accumsan lacus lacinia. Aliquam in imperdiet orci, eget tristique sapien. Aliquam malesuada vel dolor consequat finibus.</p>
</div>
</div>
</div>
</div>
</div>
</section>
<!-- END PAGE SPLIT COMPONENT 7/5 -->
<!-- MORE COMPONENTS MAY GO HERE
<section>
<div class="container-fluid p-0">
<p class="text-center">some other place to go</p>
</div>
</section>-->
</main>
</body>
</html>
html,
body {
height:100%;
}
body {
background-color: #F8F8F7;
color: #000;
font-size: 100%;
font-weight: 400;
line-height: 1.4;
margin: 0;
overflow-x: hidden;
text-align: center;
}
main {
height:100%;
width: 100%;
}
.section {
width: 100%;
height: auto;
overflow: hidden;
position: relative;
}
.container-fluid {
padding: 0;
}
/*** LAYOUT ***/
.all-vh {
height: 100vh;
}
.vertical-center {
display: table;
position: relative;
width: 100%;
height: 100%;
}
.vertical-center.vh {
height: 100%;
}
.vertical-center .vertical-el {
display: table-cell;
vertical-align: middle;
}
/*** TYPOGRAPHY ***/
p {
font-size: calc(1.25em + (3.5 - 1.25) * ((100vw - 20em) / (120 - 20)));
font-weight: 300;
line-height: 1; /* 0.85; */
text-align: left;
}
@media only screen and (min-width:1920px) {
p {
font-size: 3.5rem; /* was 4.5rem */
}
}
/*** IMAGES ***/
.img-cover {
width: 100%;
height: auto;
}
@media only screen and (min-width: 1024px) {
.img-cover {
object-fit: cover;
height: 100vh;
}
}
.img-sizing {
max-width: 100%;
height: auto;
}
@media only screen and (min-width:1920px) {
.img-sizing {
object-fit: contain;
width: 100%;
}
}
/*** COMPONENTS ***/
/* 2 IMAGE COVERUP */
.cmpnt--image-coverup .all-vh {
height: auto;
}
.panel-on-image {
position: absolute;
bottom: 0;
left: 50%;
transform: translateX(-50%);
z-index: 33;
width: 85%;
padding: 2rem;
}
/* 7/5 PAGE SPLIT */
@media screen and (orientation: landscape) {
.cmpnt--page-split .all-vh {
height: auto;
min-height: 100vh;
}
.cmpnt--page-split--text {
padding: 0 5%;
}
}
.cmpnt--page-split--image {
overflow: hidden;
width: 100%;
}
.cmpnt--page-split--image img {
width:100%;
height:100%;
object-fit:cover;
}
.cmpnt--page-split--image.rt img {
object-position: right top;
}
.cmpnt--page-split--image.lt img {
object-position: left top;
}
.cmpnt--page-split--image--border {
border-style: solid;
border-width: calc(1em + (9.375 - 1) * ((100vw - 20em) / (120 - 20)));
}
@media screen and (pointer: fine) {
.ic__image--two,
.ps__image--two {
position: absolute;
top: 0;
left:0;
}
}
.panel-on-image {
background-color:#D47E43;
background:rgba(212, 126, 67, 0.8);
}
/*** GSAP ***/
.pin-spacer {
/* background: rgba(255,0,0,0.3);*/
margin:0 !important;
}
document.addEventListener("DOMContentLoaded", function() {
gsap.registerPlugin(ScrollTrigger);
var ic__textWrapper,ic__text,ic__text_h,imageTwo,imageTwo_h,relevantElementsHeight,totalPinDuration,ic__textDuration,imageTwoDuration,ps__wrapper,ps__i2,ps__i2_h;
var ic__tl = gsap.timeline();
var ps__tl = gsap.timeline();
gsap.utils.toArray("section").forEach(function(section) {
if (section.querySelector('.cmpnt--image-coverup') !== null) {
var ic__textWrapper = section.querySelector(".panel-on-image");
var ic__text = section.querySelector(".panel-on-image p");
var ic__text_h = ic__textWrapper.offsetHeight;
var imageTwo = section.querySelector(".ic__image--two");
var imageTwo_h = imageTwo.offsetHeight;
var relevantElementsHeight = ic__text_h*2 + imageTwo_h;
var totalPinDuration = relevantElementsHeight + ((relevantElementsHeight*0.1)*5);
var ic__textDuration = ic__text_h/relevantElementsHeight;
var imageTwoDuration = imageTwo_h/relevantElementsHeight;
gsap.set(ic__text,{opacity:0});
var ic__tl = gsap.timeline({ paused: true })
ic__tl
.from(ic__textWrapper, { duration: ic__textDuration, scaleY:0, transformOrigin:("bottom center")},"+=0.1")
.to(ic__text, { duration: 0.1, opacity:1 })
.from(imageTwo, { duration: imageTwoDuration, yPercent: 100 },"+=0.1")
.to(ic__text, { duration: 0.1, opacity:0 })
.to(ic__textWrapper, { duration: ic__textDuration, scaleY:0, transformOrigin:("bottom center") },"+=0.1")
;
ScrollTrigger.create({
animation: ic__tl,
trigger: section.querySelector('.cmpnt--image-coverup'),
start: "center center",
end: () => "+=" + totalPinDuration,
scrub: true,
pin: true
});
}
if (section.querySelector('.cmpnt--page-split') !== null) {
var ps__wrapper = section.querySelector(".cmpnt--page-split");
var ps__i2 = section.querySelector(".ps__image--two");
var ps__i2_h = ps__i2.offsetHeight;
var ps__tl = gsap.timeline({ paused: true })
ps__tl.from(ps__i2, { duration: 2, yPercent: 100 },"+=0.1");
ScrollTrigger.create({
animation: ps__tl,
//id: 'ps__' + i__ps,
trigger: section.querySelector('.cmpnt--page-split'),
start: "center center",
end: () => "+=" + ps__i2_h,
scrub: true,
pin: true
});
}
});
});
Also see: Tab Triggers