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.
<!-- START Select Client Content ============== v00.53.54 ============== -->
<!-- <div id="modal" class="row selectedModal"> START Row Modal Wrap -->
<nav class="modalNav">
<ul>
<li><a href="#slide-1" class="modalNavLink"> </a></li>
<li><a href="#slide-2" class="modalNavLink"> </a></li>
<li><a href="#slide-3" class="modalNavLink"> </a></li>
<li><a href="#slide-4" class="modalNavLink"> </a></li>
</ul>
</nav>
<div class="slides-container">
<div class="slide" id="slide-1">
<div class="centered" id="print-advil-1">
<!-- Empty Div for boxFrame Overlay Clone -->
<!-- Will Fade On Scroll -->
</div>
</div>
<div class="slide" id="slide-2">
<div class="centered" id="print-advil-2">
<img src="http://hainis.net/dev/assets/img/modalPrintAdvil2c.jpg" alt="Advil Beep Beep Honk Ad">
</div>
</div>
<div class="slide" id="slide-3">
<div class="centered" id="print-advil-3">
<img src="http://hainis.net/dev/assets/img/modalPrintAdvil3c.jpg" alt="Advil Waaah Waaa Waaah Ad">
</div>
</div>
<div class="slide" id="slide-4">
<div class="centered modalDescription">
<h1 class="handwritten">Advil</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
</div>
</div>
</div>
<!-- </div> END Row Modal Wrap -->
<!-- END Select Client Content ========================================== -->
// ==================================================================
// =============== Custom Modal Javascript v00.53.56 ================
// ==================================================================
/*
Notes
- ISSUE - clone's scale path has a wierd arc (it hooks).
*/
function scrollModal() {
//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 = $(".modalNavLink").filter("[href^=\\#]");
var $navGoPrev = $(".go-prev");
var $navGoNext = $(".go-next");
var $slidesContainer = $(".slides-container");
var $slides = $(".slide");
var $currentSlide = $slides.first();
//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
}
// Going to the first slide
goToSlide($currentSlide);
// 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();
}
}; // END onNavButtonClick
// onKeyDown ===========================================================
// 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 || PRESSED_KEY == 37)
{
goToPrevSlide();
event.preventDefault();
}
else if(PRESSED_KEY == keyCodes.DOWN || PRESSED_KEY == 39)
{
goToNextSlide();
event.preventDefault();
}
}; // END onKeyDown
// onMouseWheel ===========================================================
// 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();
}
else if(delta > 1)
{
goToPrevSlide();
}
event.preventDefault();
}; // END onMouseWheel
// goToPrevSlide ===========================================================
// If there's a previous slide, slide to it
function goToPrevSlide()
{
if($currentSlide.prev().length)
{
goToSlide($currentSlide.prev());
}
}; // END goToPrevSlide
// goToNextSlide ===========================================================
// If there's a next slide, slide to it
function goToNextSlide()
{
if($currentSlide.next().length)
{
goToSlide($currentSlide.next());
}
}; // END goToNextSlide
// goToSlide ===============================================================
// 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;
//Sliding to current slide
TweenLite.to($slidesContainer, 1, {scrollTo: {y: pageHeight * $currentSlide.index() }, onComplete: onSlideChangeEnd, onCompleteScope: this});
//Animating menu items
TweenLite.to($navButtons.filter(".active"), 0.5, {className: "-=active"});
TweenLite.to($navButtons.filter("[href=\\#" + $currentSlide.attr("id") + "]"), 0.5, {className: "+=active"});
}
}; // END goToSlide
// onSlideChangeEnd ========================================================
// 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;
}; // END onSlideChangeEnd
// 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, $slides], {height: pageHeight + "px"});
//The current slide should be always on the top
TweenLite.set($slidesContainer, {scrollTo: {y: pageHeight * $currentSlide.index() }});
}
/* // No Longer Using this
// Set Var and If / Else to maintain Clone Opacity on Window Resize
var headerHeight = 100;
if ($(".slides-container").scrollTop() > headerHeight) {
$(".clone").css({ opacity: '0', display: 'none' });
} else {
$(".clone").css({ opacity: '1', display: 'block' });
}; // END else
*/
}; // END onResize
// Add closeSectionModal Button
// TESTING IN THIS LOCATION - May Need to move back to sectionContent JS
$('.overlay').prepend("<button class='closeSectionModal close-button' aria-label='Close alert' type='button' data-close><span aria-hidden='true'>×</span></button>").promise().done(function() {
// Apply click event to closeSectionModal
$(".closeSectionModal").on("click", function() {
// Unbind the event handlers/listeners from the Modal/Ovrlay Function
$window.off("resize", onResize).resize();
$window.off("mousewheel DOMMouseScroll", onMouseWheel);
$document.off("keydown", onKeyDown);
$navButtons.off("click", onNavButtonClick);
$navGoPrev.off("click", goToPrevSlide);
$navGoNext.off("click", goToNextSlide);
// Call Function
closeTile();
}); // END on click
}); // END Promise
}; // END scrollModal
// Call the function
scrollModal();
Also see: Tab Triggers