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.
<nav>
<ul>
<li>
<a href="#slide-1" id="Slide01" class="active">
<span></span>
</a>
</li>
<li>
<a href="#slide-2" id="Slide02">
<span></span>
</a>
</li>
<li>
<a href="#slide-3" id="Slide03">
<span></span>
</a>
</li>
<li>
<a href="#slide-4" id="Slide04">
<span></span>
</a>
</li>
<li>
<a href="#slide-5" id="Slide05">
<span></span>
</a>
</li>
</ul>
</nav>
<div class="slides-container">
<!--SLIDE 1-->
<div class="slide active" id="slide-1">
<div class="centered">
<h1>Section 1</h1>
<p>Here are some words</p>
</div>
</div>
<!--SLIDE 2-->
<div class="slide" id="slide-2">
<div class="cover">
<h1>Section 2</h1>
<p>Here are some more words</p>
</div>
</div>
<!--SLIDE 3-->
<div class="slide" id="slide-3">
<div class="cover">
<div class="wrapME centered">
<h1>Section 3</h1>
<p>Here are even more words</p>
</div>
</div>
</div>
<!--SLIDE 4-->
<div class="slide" id="slide-4">
<div class="cover">
<h1>Section 4</h1>
<p>Here are even more words</p>
</div>
</div>
<!--SLIDE 5-->
<div class="slide" id="slide-5">
<div class="cover">
<h1>Section 5</h1>
<p>Here are even more words</p>
</div>
</div>
</div>
<!--START OF SVG **********************************************- -->
<div class="SVG centered">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 353.86 485.3">
<defs>
<style>
.cls-1 {
fill: #5b3b82;
}
.cls-2 {
fill: #70398a;
}
.cls-3 {
fill: #b4005b;
}
</style>
</defs>
<title>Asset 17</title>
<g id="Layer_2" data-name="Layer 2">
<g id="Blobs">
<path id="Blob3" class="cls-3" d="M176.93,471.47c128.7,39.6,71-232.13,100.56-327.47C319,9.92,253.76,9.92,194.61,9.92S63.28,34.39,63.28,144s55.31,309.52,113.65,327.47"
/>
<path id="Blob2" class="cls-2" d="M163.68,448.87c53.8,44.35,104.63-77.95,104.63-174.1s-.48-285.52-80.47-241.06C132,64.77,85.54,209.48,85.54,272.64c0,69.53,66.85,166.92,78.14,176.23"
/>
<path id="Blob1" class="cls-1" d="M257.05,314c33.44-86.39.93-102.52-57.38-136.21C139,142.77,92.51,149.06,87.34,169.38c-12,47.36,1.73,93.4,61.12,133.82,24.34,16.57,93.3,50.32,108.59,10.84"
/>
</g>
</g>
</svg>
<!--END OF SVG **********************************************- -->
</div>
<script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/gsap/1.20.2/TweenMax.min.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/gsap/1.18.0/plugins/ScrollToPlugin.min.js'></script>
<script src="js/MorphSVGPlugin.min.js"></script>
<script src="js/main.js"></script>
</body>
/* USED */
body, div, p {
margin: 0;
padding: 0;
}
/* USED */
body {
font-family: "HelveticaNeue-Light", "Helvetica Neue Light", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif;
font-weight: 300;
letter-spacing: 0.0625em;
background-color: #555555;
}
img{
z-index:40;
position: absolute;
bottom: 0%;
left: 45%;
width: 500px;
}
/* USED */
a {
text-decoration: none;
color: black;
}
/* USED */
h1 {
text-align: center;
font-weight: 300;
font-size: 3em;
}
/* USED */
nav {
position: absolute;
bottom: 0%;
left: 50%;
width: 240px;
z-index: 100;
visibility: hidden;
}
/* USED */
nav ul {
margin: 0;
padding: 0;
}
/* USED */
nav ul li {
display: block;
width: 14px;
height: 13px;
margin: 7px 2px 2px 40px;
position: relative;
float: left;
}
/* USED - Need to figure out why this works*/
nav ul li:first-child {
margin-left: 0;
}
/* USED */
nav a {
display: block;
position: relative;
z-index: 1;
width: 100%;
height: 100%;
cursor: pointer;
text-decoration: none;
}
/* USED */
nav span {
border-radius: 50%;
position: absolute;
z-index: 1;
height: 4px;
width: 4px;
border: 0;
background: black;
left: 50%;
top: 50%;
margin: -2px 0 0 -2px;
-webkit-transition: all 0.1s ease-in-out;
-moz-transition: all 0.1s ease-in-out;
-o-transition: all 0.1s ease-in-out;
transition: all 0.1s ease-in-out;
}
/* USED */
a.active span {
height: 16px;
width: 16px;
margin: -9px 0 0 -9px;
border-radius: 100%;
}
/* USED */
ul li:hover span {
height: 20px;
width: 20px;
margin: -13px 0 0 -9px;
border-radius: 100%;
}
/* USED */
.slides-container {
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
overflow: hidden;
z-index: 50;
}
/* USED */
.slide {
position: relative;
width: 100%;
height: 100%;
overflow: hidden;
z-index: 10;
}
/* USED */
.slide .centered {
position: absolute;
width: 100%;
top: 40%;
left: 50%;
visibility: hidden;
}
/* USED */
.slide .centered h1 {
text-align: center;
margin: 0;
}
/* USED */
.slide .centered p {
text-align: center;
margin: 0;
font-size: 15px;
}
/* USED */
#slide-1 {
/* background-color: rgba(255, 255, 255, 0.5); */
}
/* USED */
#slide-2 {
/* background-color: #45959b; */
}
/* USED */
#slide-3 {
/* background-color: #778899; */
/* background-color: rgba(141, 141, 141, 0.5); */
}
/* USED */
#slide-4 {
/* color: rgb(77, 8, 67); */
/* background-color: #FFFFFF; */
}
/* USED */
#slide-5 {
/* color: #FFFFFF; */
/* background-color: #413257; */
/* background-color: rgba(0, 0, 0, 0.5); */
}
/* .go-prev, .go-next {
cursor: pointer;
font-weight: bold;
text-decoration: underline;
} */
/* .action {
position: absolute;
left:50%; top:50%;
width: 200px !important; height: 200px;
background: red;
} */
/* USED */
.cover {
width: 90vw;
height: 50.625vw;
max-height: 90vh;
max-width: 160vh;
margin: auto;
margin-bottom: 20px;
position: absolute;
top: 7%;
left: 0;
right: 0;
}
/* #text, #kopf02, #mund02, #mund03, #hand01, .hidden {visibility: hidden;} */
.wrapME {
position: absolute;
top: 27%;
left: 11%;
height: 75%;
width: inherit;
overflow: hidden;
}
/* .me {
height: 85%;
top: 58% !important;
} */
/* #YOU {
top: 89%;
left: 55%;
height: 8%;
} */
/* .you {
fill: none;
stroke-linecap: round;
stroke-linejoin: round;
stroke-width: 8;
stroke: #000;
} */
/*
#greenattack {width: 66%; overflow: hidden;}
.greenattack {
fill: none;
stroke-linecap: round;
stroke-linejoin: round;
stroke-width: 8px;
stroke: #000;
}
.sonne {visibility: hidden; left:0%;}
.kugel {fill: black; visibility: hidden;} */
#slide-5 .cover {
overflow: visible;
}
/* .helmut {
height: 44%;
left: 4%;
}
.rauch {
fill: none;
stroke-linecap: round;
stroke-linejoin: round;
stroke-width: 12;
stroke: #fff;
visibility: hidden;
} */
/* .close {
position: absolute;
top: -1px;
right: 25px;
font-size: 55px;
font-weight: 300;
color: #49D549;
cursor: pointer;
z-index: 1000;
}
.againPIN, .againME, .againHELMUT, .againGreenAttack {
position: absolute;
top: auto;
bottom: 5%;
right: 5%;
color: #0D6708;
cursor: pointer;
visibility: hidden;
z-index: 1000;
} */
#Blob2, #Blob3{
visibility:hidden;
}
.SVG.centered{
position: absolute;
width:50%;
left: 50%;
top: 50%;
z-index:40;
}
// ============= xxxxx ==========================
TweenMax.set(".centered, nav", { autoAlpha: 1, xPercent: -50, yPercent: -50, force3D: true });
//Forked from [Chrysto](http://codepen.io/bassta/)'s Pen [Fullscreen slides with TweenLite, CSSPlugin and ScrollToPlugin](http://codepen.io/bassta/pen/kDvmC/). Optimized with the help of Blake Owen
//First the variables our app is going to use need to be declared
//References to DOM elements
var $window = $(window);
var $document = $(document);
//Only links that starts with #
var $navButtons = $("nav a").filter("[href^=#]");
var $navGoPrev = $(".go-prev");
var $navGoNext = $(".go-next");
var $slidesContainer = $(".slides-container");
var $allSlides = $(".slide");
var $currentSlide = $allSlides.first();
var slideControl = $("nav a")
//Animating flag - is our app animating
var isAnimating = false;
//The height of the window
var pageHeight = $window.innerHeight();
//Key codes for up and down arrows on keyboard. We'll be using this to navigate change slides using the keyboard
var keyCodes = {
UP: 38,
DOWN: 40
};
var currentIndex = 0;
var timeline1 = new TimelineLite()
.reverse();
var timeline2 = new TimelineLite()
.to("#hand01", 0.5, { autoAlpha: 1, repeat: 3 }, "+=0.5")
.to("#mund01", 0.5, { morphSVG: "#mund02" }, "+=0")
.to("#kopf, #mund01", 1, { autoAlpha: 0 }, "+=1")
.to("#kopf02, #mund03", 1, { autoAlpha: 1 }, "-=1")
.to("#text", 1, { autoAlpha: 1 }, "-=0.5")
.to("#kamera", 1, { rotation: -20, transformOrigin: "50% 50%" }, "-=0.5")
.to('.againPIN', 0.5, { autoAlpha: 1 }, "+=1")
.reverse();
$(".againPIN").on("click", function () {
timeline2.restart();
});
var timeline3 = new TimelineLite({ repeat: -1, yoyo: true, repeatDelay: 0.5 })
.to("#ME", 2, { morphSVG: "#ME02", repeat: 3, yoyo: true, repeatDelay: 0.5 })
.fromTo("#YOU", 2, { y: "+110%" }, { y: "0%", repeat: 3, yoyo: true, repeatDelay: 0.5 }, 0.2)
.to('.againME', 0.5, { autoAlpha: 1 }, "+=1")
.reverse();
$(".againME").on("click", function () {
timeline3.restart();
});
var timeline4 = new TimelineLite()
.set('.sonne', { autoAlpha: 1 })
.fromTo('.sonne', 4, { x: "-150%" }, { x: "+200%", scale: 0.4, ease: Power4.easeNone }, 0)
.to('.sonne', 0.1, { autoAlpha: 0 }, "-=1")
.to('#wolke', 4, { x: "+80%", ease: Power4.easeNone }, "-=1")
.to(".rohr01", 0.07, { x: "-30px", repeat: 9, yoyo: true, repeatDelay: 0.1, ease: Power4.easeIn }, 0.8)
.to('.againGreenAttack', 0.5, { autoAlpha: 1 }, "+=1")
.reverse();
$(".againGreenAttack").on("click", function () {
timeline4.restart();
});
var timeline5 = new TimelineLite()
.set('.rauch', { autoAlpha: 1 }, "+=1")
.to('.rauch', 3, { y: "-100%", scale: 1.8, opacity: 0, repeat: 3, repeatDelay: 1 })
.to('.againHELMUT', 0.5, { autoAlpha: 1 }, "+=1")
.reverse();
$(".againHELMUT").on("click", function () {
timeline5.restart();
});
var timelines = [timeline1, timeline2, timeline3, timeline4, timeline5];
//Going to the first slide
goToSlide($currentSlide);
//TweenLite.set($currentSlide, {className: "+=active"});
/*
* Adding event listeners
* */
$window.on("resize", onResize).resize();
$window.on("mousewheel DOMMouseScroll", onMouseWheel);
$document.on("keydown", onKeyDown);
$navButtons.on("click", onNavButtonClick);
$navGoPrev.on("click", goToPrevSlide);
$navGoNext.on("click", goToNextSlide);
/*
* Internal functions
* */
/*
* When a button is clicked - first get the button href, and then slide to the container, if there's such a container
* */
function onNavButtonClick(event) {
//The clicked button
var $button = $(this);
//The slide the button points to
var $slide = $($button.attr("href"));
//If the slide exists, we go to it
if ($slide.length) {
goToSlide($slide);
event.preventDefault();
}
}
/*
* Getting the pressed key. Only if it's up or down arrow, we go to prev or next slide and prevent default behaviour
* This way, if there's text input, the user is still able to fill it
* */
function onKeyDown(event) {
var PRESSED_KEY = event.keyCode;
if (PRESSED_KEY == keyCodes.UP) {
goToPrevSlide();
event.preventDefault();
}
else if (PRESSED_KEY == keyCodes.DOWN) {
goToNextSlide();
event.preventDefault();
}
}
/*
* When user scrolls with the mouse, we have to change slides
* */
function onMouseWheel(event) {
//Normalize event wheel delta
var delta = event.originalEvent.wheelDelta / 30 || -event.originalEvent.detail;
//If the user scrolled up, it goes to previous slide, otherwise - to next slide
if (delta < -1) {
goToNextSlide();
// TweenLite.to("#ProvocationBlob", 1, {morphSVG:"#TestBlob",fill:"#FF1D25"});
}
else if (delta > 1) {
goToPrevSlide();
// TweenLite.to("#ProvocationBlob", 1, { morphSVG: "#DefineBlob",fill:"FEC601" });
}
event.preventDefault();
}
/*
* If there's a previous slide, slide to it
* */
function goToPrevSlide() {
if ($currentSlide.prev().length) {
goToSlide($currentSlide.prev());
TweenLite.to("#Blob1", 1, { morphSVG: "#Blob2",fill:"#FEC601" });
}
}
/*
* If there's a next slide, slide to it
* */
function goToNextSlide() {
if ($currentSlide.next().length) {
goToSlide($currentSlide.next());
TweenLite.to("#Blob1", 1, {morphSVG:"#Blob3",fill:"#FF1D25"});
}
}
/*
* Actual transition between slides
* */
function goToSlide($slide) {
//If the slides are not changing and there's such a slide
if (!isAnimating && $slide.length) {
//setting animating flag to true
isAnimating = true;
$currentSlide = $slide;
NextSlide = $currentSlide.next()
//Sliding to current slide
TweenLite.to($slidesContainer, 1, { scrollTo: { y: pageHeight * $currentSlide.index() }, onComplete: onSlideChangeEnd, onCompleteScope: this });
//Definig slide status
TweenLite.to($allSlides.filter(".active"), 0.1, { className: "-=active" });
TweenLite.to($allSlides.filter($currentSlide), 0.1, { className: "+=active" });
//Animating menu items
TweenLite.to($navButtons.filter(".active"), 0.5, { className: "-=active" });
TweenLite.to($navButtons.filter("[href=#" + $currentSlide.attr("id") + "]"), 0.5, { className: "+=active" });
}
}
/*
* Once the sliding is finished, we need to restore "isAnimating" flag.
* You can also do other things in this function, such as changing page title
* */
function onSlideChangeEnd() {
isAnimating = false;
// Reverse the timeline for the previous slide
timelines[currentIndex].reversed(true).progress(0);
// Change the index
currentIndex = $currentSlide.index();
// Play the timeline for the current slide
timelines[currentIndex].reversed(false);
}
/*
* When user resize it's browser we need to know the new height, so we can properly align the current slide
* */
function onResize(event) {
//This will give us the new height of the window
var newPageHeight = $window.innerHeight();
/*
* If the new height is different from the old height ( the browser is resized vertically ), the slides are resized
* */
if (pageHeight !== newPageHeight) {
pageHeight = newPageHeight;
//This can be done via CSS only, but fails into some old browsers, so I prefer to set height via JS
TweenLite.set([$slidesContainer, $allSlides], { height: pageHeight + "px" });
//The current slide should be always on the top
TweenLite.set($slidesContainer, { scrollTo: { y: pageHeight * $currentSlide.index() } });
}
}
Also see: Tab Triggers