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="wrapper">
<svg id="oscar" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 365.2 388.7">
<g id="g3067">
<path id="face" fill="#008000" d="M74.736 289.746c-21.582-15.046-58.52-123.907-3.96-190.119l85.817-7.921c85.881-30.134 79.187-36.65 126.745-14.523 76.056 31.496 53.67 179.945-2.093 214.707-28.179 17.567 6.794 88.399 49.694 96.728l-287.093-.934c44.76-18.206 58.031-79.017 30.89-97.938z"/>
<path id="hair" fill="#744614" d="M194.866 109.535c-22.716-13.231-38.287 3.873-58.618 3.32l-76.046 7.468c-19.763.2-38.515 19.481-60.202-16.596l35.646-4.15C17.443 103.076 11.366 84.343.792 73.854 21.3 84.823 36.45 73.35 50.697 58.087c7.286-9.294-2.062-11.237-7.922-16.596 17.692 4.87 35.383 5.059 53.074 3.319 13.783-3.745 10.294-12.919 3.168-23.235l41.984 27.384c6.93-6.915 3.357-13.83 0-20.745 16.063 13.176 41.945 7.495 46.736 42.32-5.235-18.775 5.032-34.598 22.972-48.959-.766 13.09-5.122 29.186 3.96 34.022C218.438 19.785 218.951 7.554 260.613 0c-10.917 0-20.897 42.724-19.011 38.171 7.48-18.059 48.992-32.863 58.618-14.936-33.916-3.946-20.781 39.675-23.764 24.064-4.005-20.965 65.416-19.8 68.124-14.936l-26.933 29.043c23.44-3.784 48.385-8.595 24.556 19.916l22.972 3.319c-18.813 44.158-53.321 25.842-81.59 32.363-29.573-2.49-53.923-21.392-88.72-7.469z"/>
<path id="path3767" fill="#f6f8f7" stroke="#000" stroke-width="2.996" d="M152.174 96.805c-28.528-19.623-76.128-13.5-70.172 37.711 9.307 80.02 154.6 20.362 70.172-37.711z"/>
<path id="path3767-1" fill="#f6f8f7" stroke="#000" stroke-width="2.996" d="M226.971 94.305c28.433-19.76 76.129-13.498 70.173 37.712-9.307 80.02-156.582 22.342-70.173-37.712z"/>
<path id="path3787" d="M156.449 228.132a7.922 7.922 0 1 1-.001-.045l-7.918.258z" transform="matrix(1.83333 0 0 1.75 -131.555 -269.608)"/>
<path id="path3787-7" d="M156.449 228.132a7.922 7.922 0 1 1-.001-.045l-7.918.258z" transform="matrix(1.83333 0 0 1.75 -41.777 -270.929)"/>
<path id="augenbrauen" fill="#744614" stroke="#000" stroke-width="8" d="M81.245 77.736c-6.515 1.796 5.33 15.029 6.815 15.312 12.5 2.383 36.008.637 52.03 7.24 11.1 12.156 29.535 20.517 47.529 17.163 23.077 3.337 36.992-8.402 49.51-19.144 15.308-25.046 21.233-11.52 34.956-11.203 2.193.051 14.963-.778 17.194-1.34l-5.333-7.408 1.373 5.428"/>
<path id="path3813" fill="none" stroke="#000" stroke-linecap="round" stroke-linejoin="round" stroke-width="5.806" d="M299.125 219.85c-2.06-16.869-4.118-16.763-6.177-25.107l2.47 13.214c-8.711 12.663-23.932 11.81-40.768 10.57l16.678 3.304c-16.472-.348-32.945 2-49.417-6.607l4.942 8.59c-22.965-10.44-47.333-16.378-78.45-.661l6.178-9.25c-18.784 10.552-34.479 7.885-50.035 4.625l14.208-5.286c-31.221 13.82-37.1 3.38-43.858-11.232l1.853-7.928-4.324 24.446"/>
<path id="path3815" stroke="#000" stroke-width="1.051" d="M104.586 217.701c18.86 8.454 28.906 2.028 46.307 3.117 28.27-21.854 51.905-2.944 72.855-.78 16.877 1.824 34.084 5.735 49.393-2.337-24.26 106.064-144.044 104.738-168.555 0z"/>
<path id="path3817" fill="#c70000" stroke="#000" stroke-width=".968" d="M155.198 231.08c13.177-6.38 25.678-10.84 33.975-3.303 13.054-7.84 22.9-1.957 32.738 3.964-20.257 60.314-51.313 50.98-66.713-.66z"/>
<path id="path3827" fill="#fff" d="M152.49 227.292a2.31 2.31 0 1 1 0-.013l-2.31.075z" transform="matrix(1.85714 0 0 1.85714 -138.156 -292.235)"/>
<path id="path3827-4" fill="#fff" d="M152.49 227.292a2.31 2.31 0 1 1 0-.013l-2.31.075z" transform="matrix(1.85714 0 0 1.85714 -48.378 -293.555)"/>
</g>
</svg>
</div>
body{
margin:0;
background:green;
}
#wrapper{
position:absolute;
top:50%;
left:50%;
width: 200px;
}
console.clear();
var oscar = document.getElementById("wrapper");
document.addEventListener("mousemove", getMouse);
oscar.style.position = "absolute"; //css
var oscarpos = {x:0, y:0};
setInterval(followMouse, 50);
var mouse = {x:0, y:0};
var dir = "right";
function getMouse(e){
mouse.x = e.pageX;
mouse.y = e.pageY;
if(mouse.x > oscarpos.x){
dir = "right";
} else {
dir = "left";
}
console.log(dir);
}
function followMouse(){
var distX = mouse.x - oscarpos.x -25;
var distY = mouse.y - oscarpos.y -100;
//Easing motion
//Progressive reduction of distance
oscarpos.x += distX/5;
oscarpos.y += distY/2;
oscar.style.left = oscarpos.x + "px";
oscar.style.top = oscarpos.y + "px";
//Apply css class
if (dir == "right"){
TweenLite.to(oscar,0.2,{x:-150});
} else {
TweenLite.to(oscar,0.2,{x:0});
}
}
TweenMax.set('#wrapper', {perspective:600,force3D:true, transformStyle:"preserve-3d"});
TweenMax.to(oscar,1,{rotationY:30, transformOrigin:"center center",repeat:-1, yoyo:true,repeatDelay:1.5});
//TweenMax.to(oscar,1,{transformOrigin:"center center",repeat:-1, yoyo:true,repeatDelay:1, scale:1.8});
CustomWiggle.create("myWiggle", {wiggles:10, type:"anticipate"});
TweenMax.to(oscar,5,{ rotationX:-50,transformOrigin:"50% 50%", repeat:-1, repeatDelay:2,ease:"myWiggle",force3D:true});
TweenMax.to('#augenbrauen',1,{transformOrigin:"center center",repeat:-1, yoyo:true,repeatDelay:1, y:3});
Also see: Tab Triggers