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.
<svg class="vivify animationObject" id="obj" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="134px" height="134px">
<defs>
<linearGradient id="PSgrad_0" x1="0%" x2="0%" y1="100%" y2="0%">
<stop offset="0%" stop-color="rgb(255,38,118)" stop-opacity="1"></stop>
<stop offset="100%" stop-color="rgb(255,45,85)" stop-opacity="1"></stop>
</linearGradient>
<filter filterUnits="userSpaceOnUse" id="Filter_0" x="25px" y="25px" width="84px" height="88px">
<feOffset in="SourceAlpha" dx="0" dy="4"></feOffset>
<feGaussianBlur result="blurOut" stdDeviation="0"></feGaussianBlur>
<feFlood flood-color="rgb(0, 0, 0)" result="floodOut"></feFlood>
<feComposite operator="atop" in="floodOut" in2="blurOut"></feComposite>
<feComponentTransfer><feFuncA type="linear" slope="0.2"></feFuncA></feComponentTransfer>
<feMerge>
<feMergeNode></feMergeNode>
<feMergeNode in="SourceGraphic"></feMergeNode>
</feMerge>
</filter>
</defs>
<path fill-rule="evenodd" fill="rgb(82, 33, 82)" d="M34.997,4.997 L99.003,4.997 C115.572,4.997 129.003,18.428 129.003,34.997 L129.003,99.003 C129.003,115.572 115.572,129.003 99.003,129.003 L34.997,129.003 C18.428,129.003 4.997,115.572 4.997,99.003 L4.997,34.997 C4.997,18.428 18.428,4.997 34.997,4.997 Z"></path>
<path stroke-width="2px" stroke="rgb(255, 255, 255)" fill="url(#PSgrad_0)" d="M34.997,4.997 L99.003,4.997 C115.572,4.997 129.003,18.428 129.003,34.997 L129.003,99.003 C129.003,115.572 115.572,129.003 99.003,129.003 L34.997,129.003 C18.428,129.003 4.997,115.572 4.997,99.003 L4.997,34.997 C4.997,18.428 18.428,4.997 34.997,4.997 Z"></path>
<g filter="url(#Filter_0)">
<path fill-rule="evenodd" fill="rgb(255, 255, 255)" d="M86.622,76.597 C85.300,80.921 82.833,84.406 79.224,87.051 C75.614,89.696 71.539,91.018 67.000,91.018 C62.461,91.018 58.386,89.696 54.776,87.051 C51.167,84.406 48.700,80.921 47.378,76.597 C47.092,75.703 47.164,74.836 47.592,73.996 C48.021,73.156 48.700,72.594 49.630,72.308 C50.523,72.022 51.390,72.093 52.230,72.522 C53.070,72.951 53.633,73.630 53.919,74.559 C54.812,77.419 56.465,79.733 58.878,81.502 C61.290,83.271 63.998,84.156 67.000,84.156 C70.002,84.156 72.710,83.271 75.122,81.502 C77.535,79.733 79.188,77.419 80.081,74.559 C80.367,73.630 80.939,72.951 81.797,72.522 C82.655,72.093 83.530,72.022 84.424,72.308 C85.317,72.594 85.979,73.156 86.408,73.996 C86.836,74.836 86.908,75.703 86.622,76.597 ZM60.138,53.275 C60.138,55.170 59.468,56.787 58.127,58.127 C56.787,59.468 55.170,60.138 53.275,60.138 C51.381,60.138 49.764,59.468 48.423,58.127 C47.083,56.787 46.413,55.170 46.413,53.275 C46.413,51.381 47.083,49.764 48.423,48.423 C49.764,47.083 51.381,46.413 53.275,46.413 C55.170,46.413 56.787,47.083 58.127,48.423 C59.468,49.764 60.138,51.381 60.138,53.275 ZM87.587,53.275 C87.587,55.170 86.917,56.787 85.577,58.127 C84.236,59.468 82.619,60.138 80.725,60.138 C78.830,60.138 77.213,59.468 75.873,58.127 C74.532,56.787 73.862,55.170 73.862,53.275 C73.862,51.381 74.532,49.764 75.873,48.423 C77.213,47.083 78.830,46.413 80.725,46.413 C82.619,46.413 84.236,47.083 85.577,48.423 C86.917,49.764 87.587,51.381 87.587,53.275 ZM101.312,67.000 C101.312,62.354 100.400,57.913 98.577,53.677 C96.755,49.442 94.315,45.796 91.259,42.741 C88.204,39.685 84.558,37.245 80.323,35.423 C76.087,33.600 71.646,32.688 67.000,32.688 C62.354,32.688 57.913,33.600 53.677,35.423 C49.442,37.245 45.796,39.685 42.741,42.741 C39.685,45.796 37.245,49.442 35.423,53.677 C33.600,57.913 32.688,62.354 32.688,67.000 C32.688,71.646 33.600,76.087 35.423,80.323 C37.245,84.558 39.685,88.204 42.741,91.259 C45.796,94.315 49.442,96.755 53.677,98.577 C57.913,100.400 62.354,101.312 67.000,101.312 C71.646,101.312 76.087,100.400 80.323,98.577 C84.558,96.755 88.204,94.315 91.259,91.259 C94.315,88.204 96.755,84.558 98.577,80.323 C100.400,76.087 101.312,71.646 101.312,67.000 ZM108.174,67.000 C108.174,74.470 106.333,81.359 102.652,87.667 C98.971,93.976 93.976,98.971 87.667,102.652 C81.359,106.333 74.470,108.174 67.000,108.174 C59.530,108.174 52.641,106.333 46.333,102.652 C40.024,98.971 35.029,93.976 31.348,87.667 C27.667,81.359 25.826,74.470 25.826,67.000 C25.826,59.530 27.667,52.641 31.348,46.333 C35.029,40.024 40.024,35.029 46.333,31.348 C52.641,27.667 59.530,25.826 67.000,25.826 C74.470,25.826 81.359,27.667 87.667,31.348 C93.976,35.029 98.971,40.024 102.652,46.333 C106.333,52.641 108.174,59.530 108.174,67.000 Z"></path>
</g>
</svg>
<div class="input-group animationPicker col-xs-12">
<div class="input-group-btn">
<button type="button" class="btn btn-primary changeOpt" data-value="prev">🔽</button>
<button type="button" class="btn btn-primary changeOpt" data-value="next">🔼</button>
</div>
<select class="form-control selectAnimation" id="anims">
<optgroup label="One-off Animations">
<option value="ball">ball</option>
<option value="pulsate">pulsate</option>
<option value="blink">blink</option>
<option value="hitLeft">hitLeft</option>
<option value="hitRight">hitRight</option>
<option value="shake">shake</option>
</optgroup>
<optgroup label="Pop Enter Animations">
<option value="popIn">popIn</option>
<option value="popInLeft">popInLeft</option>
<option value="popInRight">popInRight</option>
<option value="popInTop">popInTop</option>
<option value="popInBottom">popInBottom</option>
</optgroup>
<optgroup label="Pop Exit Animations">
<option value="popOut">popOut</option>
<option value="popOutLeft">popOutLeft</option>
<option value="popOutRight">popOutRight</option>
<option value="popOutTop">popOutTop</option>
<option value="popOutBottom">popOutBottom</option>
</optgroup>
<optgroup label="Flip Animations">
<option value="flip">flip</option>
<option value="flipInX">flipInX</option>
<option value="flipInY">flipInY</option>
<option value="flipOutX">flipOutX</option>
<option value="flipOutY">flipOutY</option>
</optgroup>
<optgroup label="Jump Animations">
<option value="jumpInLeft">jumpInLeft</option>
<option value="jumpInRight">jumpInRight</option>
<option value="jumpOutLeft">jumpOutLeft</option>
<option value="jumpOutRight">jumpOutRight</option>
</optgroup>
<optgroup label="Swoop Enter Animations">
<option value="swoopInLeft">swoopInLeft</option>
<option value="swoopInRight">swoopInRight</option>
<option value="swoopInTop">swoopInTop</option>
<option value="swoopInBottom">swoopInBottom</option>
</optgroup>
<optgroup label="Swoop Exit Animations">
<option value="swoopOutLeft">swoopOutLeft</option>
<option value="swoopOutRight">swoopOutRight</option>
<option value="swoopOutTop">swoopOutTop</option>
<option value="swoopOutBottom">swoopOutBottom</option>
</optgroup>
<optgroup label="Drive Enter Animations">
<option value="driveInLeft">driveInLeft</option>
<option value="driveInRight">driveInRight</option>
<option value="driveInTop">driveInTop</option>
<option value="driveInBottom">driveInBottom</option>
</optgroup>
<optgroup label="Drive Exit Animations">
<option value="driveOutBottom">driveOutBottom</option>
<option value="driveOutTop">driveOutTop</option>
<option value="driveOutLeft">driveOutLeft</option>
<option value="driveOutRight">driveOutRight</option>
</optgroup>
<optgroup label="Fade Enter Animations">
<option value="fadeIn">fadeIn</option>
<option value="fadeInLeft">fadeInLeft</option>
<option value="fadeInRight">fadeInRight</option>
<option value="fadeInTop">fadeInTop</option>
<option value="fadeInBottom">fadeInBottom</option>
</optgroup>
<optgroup label="Fade Exit Animations">
<option value="fadeOut">fadeOut</option>
<option value="fadeOutLeft">fadeOutLeft</option>
<option value="fadeOutRight">fadeOutRight</option>
<option value="fadeOutTop">fadeOutTop</option>
<option value="fadeOutBottom">fadeOutBottom</option>
</optgroup>
<optgroup label="Roll Enter Animations">
<option value="rollInLeft">rollInLeft</option>
<option value="rollInRight">rollInRight</option>
<option value="rollInTop">rollInTop</option>
<option value="rollInBottom">rollInBottom</option>
</optgroup>
<optgroup label="Roll Out Animations">
<option value="rollOutLeft">rollOutLeft</option>
<option value="rollOutRight">rollOutRight</option>
<option value="rollOutTop">rollOutTop</option>
<option value="rollOutBottom">rollOutBottom</option>
</optgroup>
<optgroup label="Spin Animations">
<option value="spin">spin</option>
<option value="spinIn">spinIn</option>
<option value="spinOut">spinOut</option>
</optgroup>
<optgroup label="Pull Animations">
<option value="pullUp">pullUp</option>
<option value="pullDown">pullDown</option>
<option value="pullLeft">pullLeft</option>
<option value="pullRight">pullRight</option>
</optgroup>
<optgroup label="Fold Animations">
<option value="fold">fold</option>
<option value="unfold">unfold</option>
</optgroup>
</select>
<span class="input-group-btn">
<button class="btn btn-primary" type="button" id="animate">Animate</button>
</span>
</div>
body {
text-align: center;
padding: 3rem 1rem;
}
var object = $('#obj');
var select = $('.selectAnimation');
var button = $('#animate');
var options = $('#anims option');
var valueChange = $('.changeOpt');
const ANIM_END = 'webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend';
currentAnimationActive = null;
// functions >> events
valueChange.on('click', function (e) {
e.preventDefault();
var data = $(this).attr("data-value");
var i = options.index(options.filter(":selected"));
if (i >= 0 && i < options.length - 1) {
options.eq((data === "next" ? i + 1 : i - 1)).prop("selected", true);
select.trigger("change");
}
});
select.on('change', function () {
var value = $(this).val();
object.addClass(value).one(ANIM_END, function () {
setTimeout(function () {
object.removeClass(value);
}, 500);
});
});
button.click(function (e) {
e.preventDefault();
listValue = select.val();
object.addClass(listValue).one(ANIM_END, function () {
setTimeout(function () {
object.removeClass(listValue);
}, 500);
});
});
var classNames = [];
function extract() {
$("option").each(function() {
classNames.push($(this).val());
});
}
extract();
classNames.sort();
var div = $('.names');
for (var i=0; i < classNames.length; i++) {
div.append("<p>- " + classNames[i] + "</p>");
}
Also see: Tab Triggers