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.
<div id="container">
<div id="a_a">
SCROLL DOWN THE PAGE SLOWLY and see what happens
</div>
<div id="b_b" class="b_b">
bbb
</div>
<div id="x_x" class="x_regular">
<div id="y_y" class="regular">
<div class="box">
<hr />Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y <hr />
</div>
<div class="box">
<hr />Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y <hr />
</div>
</div>
<div id="w_w" class="regular">
<div class="box">
<hr />W W W W W W W W W W W W W<hr />
</div>
<div class="box">
<hr />W W W W W W W W W W W W W<hr />
</div>
</div>
</div>
<div id="need_to_read">
<p>I NEED TO BE ABLE TO READ THIS </p>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec vitae vehicula nibh. Phasellus vel odio ultricies, pharetra quam non, pulvinar magna. Nulla lobortis lorem non orci mollis viverra. Aliquam rutrum a enim ac commodo. Phasellus volutpat bibendum massa, non fringilla urna eleifend et. Phasellus in lorem gravida, lacinia nisl in, luctus sem. Donec accumsan turpis ut dui malesuada ornare. Cras elementum dapibus neque, et dictum sem vestibulum eget. Nam vitae molestie ante. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos.
Praesent dignissim id erat eu posuere. Duis gravida nisl est, eget venenatis lorem tristique a. Nam lectus ante, suscipit in volutpat non, varius vitae arcu. Pellentesque eu nisi et ex vulputate volutpat nec a purus. Suspendisse semper mi pulvinar, rutrum lectus ullamcorper, hendrerit nibh. Donec sodales in ex ac dapibus. Fusce aliquet condimentum urna ac volutpat. Morbi vulputate finibus elit, sed sodales turpis condimentum ut. Mauris pellentesque quis lacus id dapibus. Sed vitae leo massa. Donec ultricies nisi efficitur magna tristique eleifend. Nunc ac massa sit amet odio tempus tempus nec quis dolor. Pellentesque imperdiet tincidunt tincidunt. Suspendisse augue neque, vestibulum ac semper vel, consequat a est.
In porttitor congue urna, at mattis tellus sollicitudin elementum. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Phasellus porttitor, lorem id sagittis venenatis, risus neque tincidunt diam, id dapibus mi tellus ac ipsum. Nunc eu aliquam tortor, nec ultrices leo. Donec nibh orci, tempus et semper ut, vulputate ac ipsum. Nullam non massa ac magna maximus lobortis. Nam gravida mollis pharetra. Etiam sit amet odio nibh. Donec molestie vehicula egestas. Duis elementum blandit mi. Sed non viverra nunc, nec commodo mi.
Maecenas tortor dui, fermentum vitae erat eget, sodales ultricies ligula. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus dolor tortor, varius quis ultrices vitae, malesuada nec lorem. Sed dapibus augue at efficitur posuere. Integer eget ante at nunc venenatis faucibus eget id leo. Vestibulum a erat tristique, aliquet tellus id, maximus mi. Sed purus tellus, scelerisque ut malesuada vel, hendrerit non mauris. Morbi id ex sed turpis maximus blandit vel et sem. Sed ultricies mollis volutpat. Suspendisse a felis lacinia mauris rhoncus feugiat. Integer tristique ex ac orci vehicula, a cursus tortor porta.
Proin cursus lectus vitae ante porta lobortis. Duis posuere sem ipsum, eget elementum odio dignissim nec. Sed odio metus, tincidunt sit amet venenatis sit amet, interdum ut diam. Duis ut pharetra sapien, sed pharetra mi. Integer nec efficitur quam. Nam luctus tortor nunc, et sollicitudin sem interdum sit amet. Vivamus pharetra est nisl, vel sodales nulla dignissim vel. Vestibulum nunc urna, tristique eget massa non, pretium faucibus ante. Sed at sapien augue. Donec mollis, risus et dignissim hendrerit, arcu nisi finibus risus, quis feugiat enim ligula in urna. Integer varius dolor ipsum, ut ultrices ipsum pellentesque eu. Nullam id magna eu ligula sollicitudin luctus nec sed nunc.
Integer blandit ante ac lectus scelerisque ultricies. Duis rhoncus lacus eu metus maximus dictum. In pharetra, turpis laoreet consectetur eleifend, magna leo placerat risus, ac tincidunt urna metus eu turpis. Duis sed mollis purus. Phasellus bibendum vel odio sed elementum. Nullam posuere lobortis est eget hendrerit. Curabitur imperdiet quis diam posuere malesuada. Interdum et malesuada fames ac ante ipsum primis in faucibus. Phasellus aliquam augue est, at ultricies eros fermentum ac. Fusce nibh dui, fringilla sed purus ac, eleifend ultricies dui. Nulla a ligula nec lorem vulputate porttitor. Vestibulum tristique odio non felis ultrices, a convallis tellus finibus. Fusce mollis mollis elementum. Nulla dignissim faucibus erat, interdum vestibulum elit ultricies sit amet. Curabitur et feugiat ex. Pellentesque nisi libero, aliquam ultricies rhoncus vel, pulvinar sed erat.
Fusce quis augue in libero dapibus elementum et in ligula. Cras faucibus augue quis risus laoreet, nec vestibulum risus ultricies. Suspendisse pretium orci a turpis lacinia, nec suscipit nunc rutrum. Maecenas commodo eu nisi eu porttitor. Sed consequat augue sit amet eros fringilla, vel vestibulum ante commodo. Suspendisse pellentesque lacus sit amet volutpat rhoncus. Vestibulum in tempus lectus. Quisque placerat est in magna posuere, et varius odio tincidunt. Nulla facilisi. Nam dictum finibus quam, ac ultrices tortor pretium eget.
Quisque pulvinar, arcu sit amet efficitur egestas, tellus mauris varius arcu, sit amet ultricies felis velit sit amet urna. Curabitur diam nibh, hendrerit eu placerat in, blandit id nibh. Aenean ac risus blandit, convallis mi id, molestie nisl. Donec gravida, velit sit amet vulputate porttitor, purus ante sollicitudin mauris, tempor tincidunt sapien nisl vel lectus. Cras euismod eros sed dui vulputate aliquam. Proin dignissim turpis vel purus accumsan, eget posuere urna accumsan. Aenean finibus neque commodo nunc eleifend aliquet. Duis euismod, libero ac congue suscipit, dolor nunc viverra lectus, ac lobortis metus libero sed ligula. Suspendisse potenti. Phasellus blandit ante vel libero lacinia fringilla. Cras imperdiet laoreet metus at egestas. Sed gravida porta semper. Duis nec velit posuere, varius elit at, imperdiet sapien.
Donec dapibus lorem orci, sed imperdiet ante euismod nec. Vestibulum eget nunc eget eros interdum fermentum. Phasellus tincidunt est a lacus porta porttitor. Aenean maximus blandit enim, eu tristique quam egestas at. Ut et tortor sit amet quam tristique tristique. Nullam varius, urna sit amet scelerisque molestie, eros justo maximus sem, ac sodales dolor quam vitae justo. Donec venenatis elit elit, rhoncus eleifend dui accumsan vitae. Morbi at tincidunt dolor, eget semper velit. Vivamus eleifend magna at urna ultrices, a fringilla orci suscipit. Praesent mi felis, volutpat luctus nunc egestas, aliquet interdum lacus. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia curae; Mauris consequat in est vulputate vehicula. Etiam tristique pretium urna, eu dignissim metus hendrerit sed. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Donec id est quis massa maximus fermentum at id dolor.
Duis ornare ante ac velit iaculis, et aliquam ligula hendrerit. Suspendisse potenti. Mauris tristique sem venenatis lorem dignissim, sed hendrerit nisi pharetra. Duis iaculis et diam vel tempus. Suspendisse ut consectetur erat. Suspendisse potenti. Aliquam varius leo ut ante ultricies auctor. Vivamus erat ligula, dictum in ex at, congue dictum arcu. Duis in dolor facilisis, sagittis est commodo, egestas risus. Nulla nec velit pharetra, dignissim leo ut, tempor erat. Etiam hendrerit ante nisi, nec eleifend magna dictum sed. Aenean mattis ligula at arcu elementum iaculis. Suspendisse semper nulla nulla, sit amet blandit magna rutrum fringilla. Nam rhoncus commodo arcu, nec pellentesque felis convallis eget. Sed luctus hendrerit gravida.
Praesent et odio nec massa dignissim malesuada at a felis. Nunc mollis facilisis luctus. Sed ullamcorper, nulla ac bibendum tincidunt, nisl nibh pulvinar libero, eget congue purus lacus et est. Sed nec cursus urna. Nullam euismod et purus at vulputate. Ut vel eros tincidunt, maximus sem ac, blandit magna. Donec eget ullamcorper elit, at tincidunt sapien. Aliquam nec pulvinar magna. Aliquam scelerisque rhoncus nunc ut consectetur. Sed malesuada libero nec bibendum sodales. Integer vulputate, magna at pretium cursus, tortor ante vulputate ligula, ut pulvinar elit lorem ac nibh. Fusce sodales sapien nec lectus blandit lacinia.
Vestibulum placerat id quam in feugiat. Vivamus imperdiet tortor sed justo posuere, non convallis libero congue. Fusce a ipsum a augue interdum bibendum. Aenean rutrum interdum leo, ut pellentesque turpis. Sed ac enim sit amet dui lacinia consectetur eget eu est. Aenean suscipit pretium posuere. Sed ut velit accumsan, scelerisque velit fermentum, ullamcorper massa. Donec nec felis non neque accumsan aliquet. Nam nec lacus commodo sapien viverra laoreet id ac est. Aliquam non pellentesque nunc. Praesent ut scelerisque nisl. Sed tincidunt ultrices nibh ut venenatis. Suspendisse lectus ligula, auctor vitae pharetra ac, auctor at ante. Cras dictum nulla nec libero laoreet, aliquam sodales neque commodo. Phasellus eleifend ullamcorper odio ut varius.
Aenean congue ornare ligula in convallis. Phasellus non purus cursus, finibus tellus id, efficitur justo. Sed sed ultrices leo. Fusce efficitur mollis augue, quis dapibus sapien elementum eget. Proin odio purus, fringilla a aliquet nec, vehicula a justo. Aliquam maximus fermentum mollis. Morbi tincidunt nec elit molestie faucibus. Vestibulum quis nisi enim. Integer elit urna, aliquet sed metus nec, dignissim fermentum nunc. Nullam lacinia viverra purus vitae hendrerit. Maecenas vel nibh vel nibh sodales commodo. Duis enim mi, pharetra et consectetur vel, scelerisque ut massa. Nulla maximus in enim vel cursus.
Etiam nunc enim, viverra sit amet placerat at, molestie a libero. Integer lacinia tempor velit, non volutpat ante accumsan eget. Sed sagittis maximus lectus ut interdum. Suspendisse venenatis nunc vitae eros sagittis interdum. Curabitur nec lacus laoreet, commodo nisi quis, vestibulum magna. Cras sagittis ut leo vitae consequat. Etiam egestas nisi dolor, ut egestas lectus malesuada vitae.
Mauris nisi nibh, elementum nec eleifend sit amet, volutpat ut risus. Sed elementum malesuada libero iaculis bibendum. Vivamus euismod faucibus sapien hendrerit consequat. Fusce scelerisque suscipit sem vel viverra. Nullam at neque libero. Aliquam erat volutpat. Nunc bibendum consectetur scelerisque.
</p>
</div>
</div>
body {
background-color: #222;
padding: 10px 24px;
font-family: "Signika Negative", sans-serif, Arial;
font-weight: 300;
white-space:normal;
}
#container {
width:960px;
background-color:grey;
margin:auto;
}
.box {
margin: 4px;
padding: 8px;
font-size: 22px;
flex:1 0 auto;
}
.box:nth-child(1) {
background: rgba(85, 102, 205, 1);
}
.box:nth-child(2) {
background: rgba(125, 70, 200, 1);
}
.box:nth-child(3) {
background: rgba(33, 150, 243, 1);
}
.box:nth-child(4) {
background: rgba(0, 188, 212, 1);
}
#a_a {
background:pink;
padding:100px;
}
#b_b {
top:200px;
background:white;
color:black;
text-align:center;
height:40px;
}
.x_regular {
display:flex;
flex-direction: row;
width:100%;
padding: 0px;
margin:auto;
}
.x_reorder {
position:fixed;
left:0px;
top:0px;
}
.regular {
display:flex;
flex-direction: column;
flex:1 0 40%;
padding: 0px;
margin:auto;
}
.reorder {
flex-direction: row;
left:0px;
top:0px;
}
gsap.registerPlugin(Flip);
var doodoo = 0;
// Overall Statement: Please forgive my x_x / y_y / w_w variable names
// they are not intuitively named that to help anything!
// Also forgive the use of the "doodoo" variable, but I do that to variables that I intuitively KNOW are doing something in "not the best way possible" but are beyond my expertise and knowledge of javascript at the time. They serve as sort of a place-holder for me to know "Hey, this has to have a better way, so search it out even though this code seems to be doing what you want it to be doing... you are probably getting lucky!"
// Also NOTE: the use of a body-scroll-lock.js function loaded in settings!
var fixmeTop = $('#x_x').offset().top;
var fixmeBottom = $('#x_x').offset().bottom;
var x_x_height = $('#x_x').height();
// console.log("HEIGHT ON LOAD->"+x_x_height);
var fixme = $('#x_x');
var fixme_width = $('#x_x').width();
var mustRead = $('#need_to_read');
const group_x = document.querySelector("#x_x");
const group_y = document.querySelector("#y_y");
const group_w = document.querySelector("#w_w");
function enableBodyScrollPlease() {
bodyScrollLock.enableBodyScroll("body");
// when I tried to just use the above line inside the
// Flip / Gsap's they wouldn't work! Probaly a scope thing
// that I don't fully grasp, but I made it work by
// making it its own little function here.
}
function disableBodyScrollPlease() {
bodyScrollLock.disableBodyScroll("body");
// when I tried to just use the above line inside the
// Flip / Gsap's they wouldn't work! Probaly a scope thing
// that I don't fully grasp, but I made it work by
// making it its own little function here.
}
$(window).scroll(function() {
let currentScroll = $(window).scrollTop();
if(currentScroll >= fixmeTop){
fixMeNow(currentScroll);
} else if(currentScroll <= (fixmeTop-150)) {
restoreMeNow(currentScroll);
} else {
// do nothing // this is to not reset to quickly on scrolling
// notice the 150 pixels of dead space in the math above.
// that's just to make the user have to scroll enough to change
// the deal without changing it by accident. What I call "My Dad
// uses this website-Factor" :)
}
});
function fixMeNow(x) {
doodoo++;
// if(doodoo > 0 && doodoo < 2){
if(doodoo == 1){
disableBodyScrollPlease();
const state = Flip.getState(".regular,.x_regular, .box");
// toggle the flex direction
group_x.classList.add("x_reorder");
group_w.classList.add("reorder");
group_y.classList.add("reorder");
Flip.from(state, {
absolute: true, // always leave this
duration: 0.3,
// stagger: 0.1,
ease: "power2.inOut",
onComplete () {
enableBodyScrollPlease();
gsap.to("#x_x", {
backgroundColor: "black",
duration: 0.3
});
console.log("HEIGHT on Complete->"+$('#x_x').height());
// the above line is so the "must_read_this" div scooches down enough to stay visible after the goodness covers it up with the flip.
let new_height = $('#x_x').height()+40;
gsap.to(mustRead, {
paddingTop:new_height,
duration:0.3
});
}
});
} else {
// do nothing
console.log("doing_nothing");
}
console.log(doodoo);
}
function restoreMeNow(x) {
if(doodoo == 0){
// do nothing
console.log("doing_nothing");
} else {
const state = Flip.getState(".regular,.x_regular,.box");
// // toggle the flex direction
group_x.classList.remove("x_reorder");
group_y.classList.remove("reorder");
group_w.classList.remove("reorder");
Flip.from(state, {
absolute: true, // always leave this
duration: 0.3,
// stagger: 0.1,
ease: "power2.inOut",
onComplete() {
gsap.to("#x_x", {
backgroundColor: "transparent",
duration: 0.3
});
gsap.to(mustRead, {
padding: "10px",
duration:0.3
});
},
});
}
doodoo = 0;
console.log(doodoo);
}
Also see: Tab Triggers