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="initial-loader" class="padded"><span id="loader-text"></span></div>
<div id="main-body">
<section id="page-structure" class="ajax">
<header class="eliza height-95 black back-block-green-bottom-right">
<nav class="padded">
<a href="http://nclud.com" target="_blank"><img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/141552/logo.svg" id="nclud-logo"></a>
</nav>
<div class="header-text grid_row padded-horizontal">
<h2 class="grid2">Revolutionary is our baseline. Different is our first step. And radical means we’re just getting started.</h2>
<h1 class="grid3">We are nclud.</h1>
</div>
<div id="canvas">
<img id="image" src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/141552/header-home-fallback.jpg" data-fallback="https://s3-us-west-2.amazonaws.com/s.cdpn.io/141552/header-home-fallback.jpg">
</div>
</header>
</section>
</footer>
#page-structure{
height: 100vh;
}
.header-text {
h2, h1{
font-family: HelveticaNeue, Helvetica, Arial, "Lucida Grande", sans-serif !important;
font-weight: 900 !important;
}
}
$(document).ready(function() {
// CANVAS & MOBILE TEST
var windowWidth = $(window).width(),
windowHeight = $(window).height();
var isMobile = navigator.userAgent.match(/mobile/i);
var webGLTrue = false;
if (window.WebGLRenderingContext) {
webGLTrue = true;
}
// CLASSES
if (isMobile) {
$('body').addClass('mobile');
}
else if (!isMobile) {
$('body').addClass('desktop');
}
// GLOBAL VARIABLES
var img,
canvas,
container,
imgRatio,
containerRatio;
var screenShotCanvas,
canvasDataURL,
canvasImage,
screenCaptured = false,
animateable = true,
popstate = false,
isFourOhFour = false,
inputReady = true;
var seriously,
sourceImage,
layers,
edge,
blend1,
linearGreen,
scale1,
blend2,
linearPurple,
scale2,
blend3,
blend4,
blend5,
target;
// INITIAL LOAD FUNCTIONS
startupFunctions();
$(window).load(function(){
if (webGLTrue) {
captureScreen();
}
initialLoader();
});
function startupFunctions() {
if (isMobile) {
$('body').removeClass('noscroll');
}
widowControl();
}
// IMAGE FUNCTIONS
function imageFunctions() {
var slickDrag = false;
if (isMobile) {
slickDrag = true;
}
}
// DEBOUNCE FUNCTION
function debounce(func, wait, immediate) {
var timeout;
return function() {
var context = this, args = arguments;
var later = function() {
timeout = null;
if (!immediate) func.apply(context, args);
};
var callNow = immediate && !timeout;
clearTimeout(timeout);
timeout = setTimeout(later, wait);
if (callNow) func.apply(context, args);
};
};
var debounceAdjust = debounce(function() {
widowControl();
}, 50);
window.addEventListener('resize', debounceAdjust);
// WIDOW CONTROL
function widowControl() {
windowWidth = $(window).width();
var widowElements = $('h1, h2, h3, h4, h5, h6, li, p, figcaption, .case-study-tagline, .large-cta').not('.discovery_cell p, #site-nav li, footer li');
widowElements.each(function() {
$(this).html($(this).html().replace(/ /g, ' '));
});
if (windowWidth > 640) {
widowElements.each(function() {
$(this).html($(this).html().replace(/\s((?=(([^\s<>]|<[^>]*>)+))\2)\s*$/,' $1'));
});
}
};
// HTML CANVAS & INITIAL LOAD FUNCTIONS
function captureScreen() {
html2canvas($('.ajax'), {
letterRendering: true,
allowTaint: true,
onrendered: function(canvas){
screenShotCanvas = canvas;
canvasDataURL = screenShotCanvas.toDataURL();
canvasImage = new Image();
canvasImage.src = canvasDataURL;
screenCaptured = true;
console.log(canvas);
}
});
}
function initialLoader() {
$('body').removeClass('noscroll');
var loadText = 'Warning: Intrusion detected.';
var loaderDone = false;
$.each(loadText.split(''), function(i, letter){
setTimeout(function(){
$('#loader-text').html($('#loader-text').html() + letter);
}, 60*i);
});
setTimeout(function(){
loaderDone = true;
}, 1700);
//check to make sure the document has been fully loaded before removing loader
var readyStateCheckInterval = setInterval(function() {
if (document.readyState === "complete" && loaderDone ) {
clearInterval(readyStateCheckInterval);
$('#initial-loader').velocity({
translateZ: 0,
opacity: 0
}, {
display: 'none',
delay: 0,
duration: 800
});
if (webGLTrue) {
loadPageCanvas();
setTimeout(function(){
removePageCanvas();
$('#initial-loader').remove();
}, 500);
}
else {
setTimeout(function(){
$('#initial-loader').remove();
}, 1001);
}
}
}, 10);
}
// GLITCHING
function initializeGlitch(image, height) {
var container,
stats;
var camera,
scene,
sceneBG,
renderer,
composer,
composerScene;
var mesh,
light,
dotEffect,
shiftEffect,
sepiaEffect;
var glitchDtSize = 100,
glitchDelay = 1,
glitchAmplification = .5;
var fps = 20;
if (isFourOhFour) {
fps = 5;
}
var SCREEN_WIDTH = window.innerWidth;
var SCREEN_HEIGHT = height;
var ratio = SCREEN_WIDTH / SCREEN_HEIGHT;
if (height > 4096){
SCREEN_HEIGHT = 4096;
}
var windowHalfX = window.innerWidth / 2;
var windowHalfY = height / 2;
var delta = 0.1;
function init(){
scene = new THREE.Scene();
sceneBG = new THREE.Scene();
camera = new THREE.OrthographicCamera( -windowHalfX, windowHalfX, windowHalfY, -windowHalfY, 1, 10000 );
camera.position.z = 100;
//background
background = new THREE.MeshBasicMaterial({
map: THREE.ImageUtils.loadTexture(image),
depthTest: false
});
background.map.needsUpdate = true;
var plane = new THREE.PlaneBufferGeometry(1, 1);
var bgMesh = new THREE.Mesh(plane, background);
bgMesh.position.z = 1;
bgMesh.scale.set( SCREEN_WIDTH, height, 1 );
sceneBG.add(bgMesh);
bgMesh.material.map.needsUpdate = true;
var sceneMask = new THREE.Scene();
renderer = new THREE.WebGLRenderer();
renderer.setClearColor( 0xffffff );
renderer.setSize( window.innerWidth, window.innerHeight );
renderer.setPixelRatio( window.devicePixelRatio );
renderer.autoClear = false;
renderer.gammaInput = true;
renderer.gammaOutput = true;
renderBackground = new THREE.RenderPass( sceneBG, camera);
$(renderer.domElement).attr('id', 'loader').css('height', height);
$('#main-body').append( renderer.domElement );
var rtParameters = { minFilter: THREE.LinearFilter, magFilter: THREE.LinearFilter, format: THREE.RGBFormat, stencilBuffer: true };
var clearMask = new THREE.ClearMaskPass();
composer = new THREE.EffectComposer( renderer, new THREE.WebGLRenderTarget( SCREEN_WIDTH, SCREEN_HEIGHT, rtParameters ) );
renderScene = new THREE.TexturePass( composer.renderTarget2 );
composer.addPass(renderBackground);
composer.addPass(clearMask);
composer1 = new THREE.EffectComposer( renderer, new THREE.WebGLRenderTarget( SCREEN_WIDTH, SCREEN_HEIGHT, rtParameters ) );
var glitch = new THREE.GlitchPass(glitchDtSize, glitchDelay, glitchAmplification);
glitch.renderToScreen = true;
composer1.addPass(renderScene);
composer1.addPass(glitch);
renderScene.uniforms[ 'tDiffuse' ].value = composer.renderTarget2;
}
function render() {
renderer.clear();
composer.render(delta);
composer1.render(delta);
}
function animate() {
if (animateable){
setTimeout(function(){
render();
requestAnimationFrame( animate );
}, 1000 / fps);
}
}
init();
animate();
}
function loadPageCanvas() {
$('html').velocity('scroll', {
axis: 'y',
duration: 1000,
mobileHA: false
});
animateable = true;
initializeGlitch(canvasDataURL, screenShotCanvas.height);
$('#loader').velocity({
opacity: [1, 0]
}, {
duration: 1000
});
}
function removePageCanvas() {
$('#loader').velocity({
opacity: 0
}, {
delay: 500,
duration: 1000
});
setTimeout(function(){
animateable = false;
$('#loader').remove();
}, 1600);
}
function loadPageStatic() {
$('body').prepend('<div id="initial-loader" class="padded" style="opacity: 0;"><span id="loader-text"></span></div>');
$('#initial-loader').velocity({
translateZ: 0,
opacity: 1
}, {
duration: 150
});
}
function removePageStatic() {
var loadText = 'Loaded';
$.each(loadText.split(''), function(i, letter){
setTimeout(function(){
$('#loader-text').html($('#loader-text').html() + letter);
}, 60*i);
});
$('#initial-loader').velocity({
translateZ: 0,
opacity: 0
}, {
display: 'none',
delay: 900,
duration: 500
});
setTimeout(function(){
$('#initialLoader').remove();
}, 1401);
}
});
Also see: Tab Triggers