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="wall"></div>
<svg id="egon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 171 374">
<g id="layer1" transform="translate(-70.591 -353.66)">
<path id="rechtesBein" class="legs" fill="#f8c699" stroke="#0e1111" stroke-width="2.539" d="M163.116 654.67c-.037 7.574-5.342 51.605-5.714 55.344 2.29 9.366 2.139 7.73.655 11.72-4.104 3.975-3.778 1.692-13.091.747-1.467.073-6.27 2.323-19.86 2.75-7.197-.93-3.86-8.191.154-9.834 13.427 1.113 12.204.11 21.918-3.632l1.905-60.953"/>
<path id="linkesBein" class="legs" fill="#f8c699" stroke="#0e1111" stroke-width="2.539" d="M186.684 658.874c-.037 7.572-1.896 48.47-2.269 52.21 2.29 9.365 2.14 7.73.655 11.72-4.103 3.975-3.777 1.69-13.09.746-1.467.073-6.271 2.323-19.86 2.75-7.197-.93-3.86-8.19.153-9.833 13.428 1.112 12.205.11 21.919-3.633l1.591-49.676"/>
<g id="rechterArm" class="hidden">
<path id="smartArm" fill="#f8c699" stroke="#0e1111" stroke-linejoin="round" stroke-opacity=".993" stroke-width="3.039" d="M182.05 554.854c-27.01 17.02-70.67 48.923-81.03 51.064-20.787 1.02-18.013-1.578-17.547-6.282.646-3.713 4.001-2.706 4.757 2.204 1.162-7.532 4.166-2.803 4.942.07 2.026-6.242 7.319-4.447 8.327 3.086 1.396-3.948-4.257-.763 1.743-10.469 7.683-9.426 45.655-30.247 68.06-44.405"/>
<path id="smart" fill="#696869" stroke="#0e1111" stroke-linejoin="round" stroke-width="1.1" d="M72.765 598.12l5.571-13.913 39.265 10.496-6.108 13-8.736-2.121c-1.184-1.796-1.206-4.281-2.121-5.915-2.462-2.078-2.943-2.719-7.334-.015-1.886-1.735-3.504-3.56-5.47-1.75-1.567-.64-3.609-3.037-5.978 2.784z"/>
</g>
<path id="corpus" fill="#f8c699" stroke="#0e1111" stroke-linejoin="round" stroke-width="2.539" d="M194.414 536.265c19.763 15.637 20.174 75.016 17.494 97.74-4.676 21.284-16.184 29.093-36.58 31.93-20.524 2.175-51.31-1.86-51.787-19.82-.608-22.813 3.243-77.245 23.93-103.2"/>
<g id="head">
<path id="augeLinks" fill="#ede2d5" stroke="#0e1111" stroke-opacity=".997" stroke-width="1.931" d="M142.73 425.115c1.087 7.388 6.995 12.64 13.198 11.727 6.197-.912 10.34-7.644 9.253-15.032-1.088-7.393-6.996-12.64-13.193-11.728-6.202.913-10.347 7.64-9.259 15.033z" class="augen"/>
<path id="path4233" fill="#f8c699" stroke="#0e1111" stroke-width="2.138" d="M180.878 546.004c30.477-5.158 27.168-58.678 30.77-102.3l2.719-64.557-40.261 6.687c-7.57 9.942-13.897 24.077-17.432 47.635-42.73 18.318-31.017 22.978-15.916 26.787-3.536 26.077-15.595 47.281 10.213 90.151"/>
<path id="augeRechts" fill="#fbefdb" stroke="#0e1111" stroke-opacity=".997" stroke-width="1.908" d="M160.057 427.41c1.464 9.944 9.33 17.023 17.566 15.81 8.237-1.212 13.726-10.257 12.262-20.2-1.464-9.945-9.326-17.024-17.563-15.812-8.237 1.213-13.729 10.258-12.265 20.202z" class="augen"/>
<path id="path4257" fill="#0f1313" d="M208.679 436.504l7.037 8.894c21.382-13.602 10.67-28.291 11.682-42.582.673-5.046 4.794-7.09 12.476-6.038l-.34-4.918-6.917-5.47-1.038-17.42c-10.296 15.574-17.244 7.643-23.582-4.549-47.034-17.588-34.566-7.653-23.02 1.868l-28.817 9.204.021 5.347 16.825-2.476-9.374 9.012c17.035-2.847 27.705-1.23 45.405 1.74-2.772 6.897-3.332 2.033 1.297 22.323l-1.55 25.815"/>
<path id="path4235" fill="#f8c699" stroke="#000" stroke-width="2.138" d="M205.337 442.346c26.876-9.312 30.838 22.874-2.836 11.874"/>
<path id="pupilleRechts" fill="#0f1313" d="M170.55 433.513c.131.899 1.464 1.445 2.975 1.223 1.511-.222 2.632-1.13 2.5-2.029-.133-.898-1.466-1.445-2.978-1.223-1.511.223-2.63 1.13-2.498 2.03z" class="pupille"/>
<path id="pupilleLinks" fill="#0f1313" d="M149.466 429.551c.133.898 1.466 1.445 2.977 1.223 1.51-.223 2.631-1.13 2.5-2.03-.133-.898-1.466-1.444-2.979-1.222-1.51.223-2.63 1.13-2.498 2.029z" class="pupille"/>
<path id="mund" fill="none" stroke="#0e1111" stroke-width="2.26" d="M135.778 514.006c11.45-6.468 7.99-13.123 21.614-4.837"/>
</g>
<path id="arm" fill="#f8c699" stroke="#0e1111" stroke-linejoin="round" stroke-width="2.795" d="M195.354 558.498l-12.21 48.417-9.006 35.714.69 11.855c-2.386 7.824-8.348 11.488-4.611 1.136-3.56 5.053-7.002 10.159-4.577-1.904-4.28 10.768-7.269 6.981-6.7-2.195-3.137 10.32-13.06 18.787-4.098-4.381l4.977-9.576c6.053-9.21 11.958-27.09 15.25-39.75 3.717-14.282 4.549-23.683 6.836-39.75"/>
<path id="arm02" fill="#f8c699" stroke="#0e1111" stroke-linejoin="round" stroke-width="2.795" d="M195.216 557.958l-14.09 45.284-61.51-21.457-.926 2.16c-2.386 7.823-6.434 9.89-3.972 1.453-3.56 5.054-6.364 7.606-5.216-2.223-3.96 9.174-5.992 8.258-5.423-.918-3.137 10.32-14.018 19.425-5.056-3.743l4.658-9.576c6.053-9.21 69.574 24.025 72.868 11.365 3.715-14.282 2.93-6.713 5.218-22.78" class="hidden"/>
<path id="mund02" class="hidden" fill="none" stroke="#0e1111" stroke-width="2.093" d="M135.971 507.781c7.485 10.547 10.508 9.744 22.738-1.195"/>
</g>
</svg>
body {
width: 100%;
height: 100vh;
margin: 0;
background: #373c3b;
overflow:hidden;
}
#wall{
position: absolute;
width: 100%;
height: 86%;
top: 0;
background: grey;
z-index: -1;
}
#piece{
height: 50vh;
max-height: 820px;
position: relative;
width: calc(50vh * 0.774);
left: 100px;
top:40px;
visibility:hidden;
}
#frame{
background: url(https://s3-us-west-2.amazonaws.com/s.cdpn.io/141041/banksy-frame.png);
background-size: cover;
height: 100%;
position: absolute;
width: 100%;
-webkit-box-shadow: 4px 6px 32px 0px rgba(0,0,0,0.45);
-moz-box-shadow: 4px 6px 32px 0px rgba(0,0,0,0.45);
box-shadow: 4px 6px 32px 0px rgba(0,0,0,0.45);
}
#holder{
background-image: url(https://s3-us-west-2.amazonaws.com/s.cdpn.io/174563/240.jpeg);
background-size: cover;
height: calc(50vh * 0.69);
left: 18.8%;
position: absolute;
top: 15.3%;
width: calc(50vh * 0.774 * 0.617);
}
#painting{
height: 100%;
position: absolute;
width: 100%;
}
#original{
height: 100%;
position: absolute;
top: 0;
width: 100%;
-webkit-box-shadow: 4px 1px 32px 0px rgba(0,0,0,0.45);
-moz-box-shadow: 4px 1px 32px 0px rgba(0,0,0,0.45);
box-shadow: 4px 1px 32px 0px rgba(0,0,0,0.45);
overflow:hidden;
}
img{
position:absolute;
width:auto;
height:100%;
}
#wrapperSVG{
position: absolute;
width:100%;
height:100%;
height:90%;
top: 0;
overflow:hidden;
}
#shredded{
position: absolute;
top:101%;
stroke-width:3px;
stroke:grey;
}
#egon {
position:absolute;
top: 10vh;
height: 83vh;
overflow:visible;
filter: drop-shadow(10px -5px 10px #373c3b);
visibility:hidden;
}
.hidden{
visibility:hidden;
}
#info{
position: absolute;
width: 80px;
left: auto;
right: 6px;
top: 0px;
padding: 10px;
font-size: 20px;
text-align: center;
cursor: pointer;
z-index: 2;
}
#infoContent{
position: absolute;
top:0;
height:100%;
width:100%;
background:grey;
text-align: center;
z-index: 1;
visibility:hidden;
}
h1{
font-size: 20px;
font-family: sans-serif;
margin-top: 30px;
}
a{
font-size: 17px;
font-family: sans-serif;
font-weight: bold;
margin-top: 30px;
color: black;
text-decoration: none;
}
console.clear();
window.onload = function () {
var ww = window.innerWidth;
var vh = window.innerHeight;
var egon = $("#egon");
var sizeEgon = $("#egon").width();
var legs = $(".legs");
var head = $("#head");
var mund = $("#mund");
var corpus = $("#corpus");
var speed = ww / 5;
var start = egon.offset().left;
// based on https://codepen.io/osublake/pen/3f8b76a324743b25b786026d5b711fff
var requestId = null;
window.addEventListener("resize", function() {
if (!requestId) {
requestId = requestAnimationFrame(resize);
}
});
function buildTimeline(progress = 0, reversed = false) {
function walk(target) {
var walking = new TimelineMax({});
for (var i = 0; i < target; i++){
ww = window.innerWidth;
start = egon.offset().left;
var end = ww * target;
var dist = end - start;
if (dist < 0) {
dist = dist * -1;
}
var time = dist / speed;
walking.to(egon,time,{
x:end,ease:Sine.easeInOut,onComplete:newStartPosition})
function newStartPosition(){
start = egon.offset().left;
console.log("start = " + start);
}
console.log("start = " + start);
console.log("time = " + time);
console.log("distance = " + dist);
console.log("speed = " + dist / time);
}
return walking;
};
// ========= main ========
main = new TimelineMax({})
.set(egon,{autoAlpha:1, x:ww })
.add(walk(0.6))
.add(walk(0.01),"+=1")
.to(egon,1.5,{rotationY:-180, tranformOrigin:"center center", ease: Power3.easeIn})
.add(walk(1.1), "+=1")
.progress(progress)
.reversed(reversed);
}
buildTimeline();
function resize() {
ww = window.innerWidth;
vh = window.innerHeight;
var progress = main.progress();
var reversed = main.reversed();
main.seek(0).clear();
buildTimeline(progress, reversed);
requestId = null;
}
}
Also see: Tab Triggers