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.
<body>
<div class="mobileframe"></div>
<div class="trigger"><h1>start scrolling</h1></div>
<div class="frame">
<div class="overlay">
<h1 class="framenumber" id="framesequencenumber">
127
</h1>
</div>
<img class="image" id="imgsequence" src="http://399.michaelkennedy.ch/bw_frames/0000.jpg" />
</div>
<div class="pageExtender"></div>
<div class="dllink">
<a id="higreslink" href="" download>download image</a>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/1.14.2/TweenMax.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/ScrollMagic/2.0.7/ScrollMagic.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/ScrollMagic/2.0.7/plugins/debug.addIndicators.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/ScrollMagic/2.0.7/plugins/animation.gsap.min.js"></script>
<script src="js/main.js"></script>
</body>
body{
font-family: Arial, Helvetica, sans-serif;
margin: 0;
background-color: black;
}
.trigger{
position: absolute;
left: 50%;
top: 25%;
transform: translate(-50%, -50%);
color: white;
width: 20em;
text-align: center;
z-index: 1;
font-size: 2vh;
}
.mobileframe{
position: fixed;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
width: 94%;
height: 96%;
border: solid 20px white;
z-index: 1;
opacity: 0;
}
.frame {
position: fixed;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
width: 100%;
height: 80vh;
opacity: 1;
}
.overlay {
position: fixed;
text-align: center;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
mix-blend-mode: difference;
}
.framenumber{
font-size: 24vh;
color: white;
}
.image {
height: 100%;
display: block;
margin: auto;
}
.dllink a{
position: fixed;
left: 50%;
top: 95%;
transform: translate(-50%, -50%);
z-index: 2;
white-space: nowrap;
color: #FFFFFF;
-webkit-border-radius: 20px;
-moz-border-radius: 20px;
border-radius: 20px;
height: 10px;
line-height: 10px;
text-align: center;
font-size: 16px;
font-weight: 100;
padding: 13px 23px ;
background-color: #000000;
text-decoration: none;
display: inline-block;
cursor: pointer;
}
.pageExtender {
height: 20800px;
background-color:black;
}
@media screen and (max-width: 420px) {
.frame {
height: 100%;
}
.dllink a{
top: 90%;
}
}
//This script lets you scroll through an image sequence with a correlating number sequence on top of the image. It also creates a download link to a higres image, of the displayed image, located in a separate directory.
//Works on desktop and mobile.
// based on https://scrollmagic.io/examples/expert/image_sequence.html
// low res and highres images need to be stored in seperate directories with the same file name and named: 0000.fileType, 0001.fileType, 0002.fileType, ...
// works on desktop and mobile!
// include
//jquery https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js
//GSAP https://cdnjs.cloudflare.com/ajax/libs/gsap/1.14.2/TweenMax.min.js
//scrollmagic https://cdnjs.cloudflare.com/ajax/libs/ScrollMagic/2.0.7/ScrollMagic.min.js
//GSAP animation https://cdnjs.cloudflare.com/ajax/libs/ScrollMagic/2.0.7/plugins/animation.gsap.min.js
//scrollmagic debug indicators https://cdnjs.cloudflare.com/ajax/libs/ScrollMagic/2.0.7/plugins/debug.addIndicators.min.js
// define these vars to your needs
var framePath = "http://399.michaelkennedy.ch/bw_frames/"; //Define file path for your images
var highResPath = "http://399.michaelkennedy.ch/bw_frames/"; //if you have a downloadable high res image, define its path here.
var nFrames = 400; //Define amount of images. counting starts at 0, to have it count to 400 you would have to ad 401 images.
var fileType = ".jpg"; //Define your image file type.
var pageLengt = 20000; // this defines over what distance, in pixels, your image sequence should be displayed. esentally it defines how speady you scroll trough all the individual images. make shure your page has at least this lengt in px aswel.
//no need to change anything further down here.
//Define arrays.
var images = []; //Define array for images
var numberSequence = []; //Define array for number sequence
var higresimages =[]; //Define array for higres images
// ad images with path to array
function pad(number, length) { // pad numbers with leading zeros for your image sequence
var str = '' + number;
while (str.length < length) { str = '0' + str; }
return str;
}
for (i = 0; i < (nFrames); i++) {//loop through all pictures
images.push(framePath +pad(i, 4) + fileType); //Add every image to array with pad numbers and file type
}
// ad higres images with path to array
for (i = 0; i < (nFrames); i++) {//loop through all pictures
higresimages.push(highResPath +pad(i, 4) + fileType); //Add the higResPath to the array with pad numbers and file type
}
// ad numbers to numbersequence array
for (i = 0; i < (nFrames); i++) {
numberSequence.push(i); //Add N numbers to array
}
// TweenMax can tween any property of any object. We use this object to cycle through the array
var obj = {curImg: 0};
// create tween
var ImageSequenceTween = new TimelineMax()
.to(obj, 0.5,
{
curImg: images.length - 1, // animate propery curImg to number of images
roundProps: "curImg", // only integers so it can be used as an array index
repeat: 0, // repeat 3 times
immediateRender: true, // load first image automatically
ease: Linear.easeNone, // show every image the same ammount of time
onUpdate: function () {
$("#imgsequence").attr("src", images[obj.curImg]);// set the image source
$("#framesequencenumber").text(numberSequence[obj.curImg]);// set sequence number
$("#higreslink").attr("href", higresimages[obj.curImg]);// set higres download link path
}
}
)
// When the DOM is ready
$(function() {
// init controller
var ImageSequenceController = new ScrollMagic.Controller();
// build scene --> image sequence
var scene = new ScrollMagic.Scene({
triggerElement: ".trigger",
triggerHook: 0,
offset: -100,
duration: pageLengt,
})
.setTween(ImageSequenceTween)
//.addIndicators() // add indicators (requires plugin)
.addTo(ImageSequenceController);
});
Also see: Tab Triggers