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 version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 800 600" enable-background="new 0 0 800 600" xml:space="preserve">
<g id="button">
<circle id="circle" fill="#CCCDDD" stroke="#FFF" stroke-width="8" stroke-miterlimit="10" cx="400" cy="300" r="82"/>
<g id="arrowGroup">
<line fill="none" stroke="#FFF" stroke-width="8" stroke-linecap="round" stroke-miterlimit="10" x1="400" y1="335" x2="423" y2="312"/>
<line fill="none" stroke="#FFF" stroke-width="8" stroke-linecap="round" stroke-miterlimit="10" x1="400" y1="335" x2="377" y2="312"/>
<line fill="none" stroke="#FFF" stroke-width="8" stroke-linecap="round" stroke-miterlimit="10" x1="400" y1="335" x2="400" y2="265"/>
</g>
<polyline id="tick" fill="none" stroke="#6247AA" stroke-width="8" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" points="
438.093,269.713 399.763,334.862 361.907,311.267"/>
<g id="circleFill">
<path fill="none" stroke="#6247AA" stroke-width="9" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" d="
M400,382c45.287,0,82-36.713,82-82s-36.713-82-82-82s-82,36.713-82,82S354.713,382,400,382"/>
</g>
</g>
<g id="speedLines">
<line fill="none" stroke="#A879D8" stroke-width="2" stroke-miterlimit="10" x1="402.25" y1="329.331" x2="402.25" y2="296.501"/>
<line fill="none" stroke="#A879D8" stroke-width="2" stroke-miterlimit="10" x1="397.75" y1="319.58" x2="397.75" y2="294.33"/>
</g>
<g id="speedLinesDown">
<line fill="none" stroke="#A879D8" stroke-width="2" stroke-miterlimit="10" x1="398.18" y1="253.857" x2="398.18" y2="286.687"/>
<line fill="none" stroke="#A879D8" stroke-width="2" stroke-miterlimit="10" x1="402.68" y1="263.608" x2="402.68" y2="288.858"/>
</g>
<g id="dots">
<ellipse id="dot" fill="#6247AA" cx="400" cy="382" rx="5" ry="5"/>
<ellipse id="arrowDot" fill="#FFF" cx="400" cy="335" rx="4" ry="4"/>
</g>
</svg>
html,body {
height:100%;
}
body {
overflow:hidden;
background:#CCCDDD;
}
svg {
width:100%;
height:100%;
visibility:hidden;
}
#button {
cursor:pointer;
}
// Initial configuration
TweenMax.set("svg",{visibility:"visible"})
TweenMax.set("#tick",{drawSVG:"0% 0%"})
TweenMax.set("#circleFill path ",{drawSVG:"0% 0%"})
TweenMax.set('#speedLines line',{drawSVG:"10% 10%",y:-10})
TweenMax.set('#speedLinesDown line',{y:12})
TweenMax.set("#dot",{opacity:0})
TweenMax.set('#arrowDot',{opacity:0})
var masterTl = new TimelineMax({
paused:false,onStart: function(){
// fix tick stroke with round join is visible on repeat/restart
TweenMax.set("#tick",{opacity:0})
}
}
);
function arrowOut() {
var tl = new TimelineMax();
// arrow to 0
tl.to('#arrowGroup line',0.5,{
drawSVG:"0% 0%",
ease:Power4.easeIn
},'in')
// move arrowDot to circle stroke
//.to('#arrowDot',0.15,{y:47,ease:Power1.easeIn},'in+=0.4')
//.to('#arrowDot',0,{opacity:0})
return tl;
}
function drawCircle() {
var tl = new TimelineMax();
// Animating the circle fill
tl.fromTo("#circleFill path",0.8,{
drawSVG:"0%",
immediateRender:false
},
{
drawSVG:"100%",
ease:Sine.easeIn
},'in+=0.25')
.to("#circleFill",0.8,{
rotation:'-=360',
transformOrigin:"center center",
ease:Sine.easeIn
},'in+=0.25')
return tl;
}
function throwDot() {
var tl = new TimelineMax();
// throw dot
tl.to('#dot',0.01,{
opacity:1
})
.to('#dot',0.2,{
y:-100,
attr:{rx:2.5},
immediateRender:false,
ease:Circ.easeOut
},"ballUp")
.to('#dot',0.2,{
attr:{rx:4},
ease:Back.easeOut
},'ballUp+=0.2')
.to('#dot',0.25,{
attr:{ry:2.5},
y:-49,
immediateRender:false,
ease:Power4.easeIn
},'ballUp+=0.35')
return tl;
}
function drawLinesUp() {
var tl = new TimelineMax();
// draw speed lines
tl.fromTo('#speedLines line',0.10,{
drawSVG:"20% 20%"
},{
drawSVG:"75%"
})
.fromTo('#speedLines line',0.15,{
drawSVG:"75%",immediateRender:false
},{
drawSVG:"0% 0%",
y:0
})
return tl;
}
function drawLinesDown() {
var tl = new TimelineMax();
// lines down
tl.fromTo('#speedLinesDown line',0.10,{
drawSVG:"30% 30%"
},
{
drawSVG:"75%"
})
.fromTo("#speedLinesDown line",0.15,{
drawSVG:"75%",
immediateRender:false
},
{
drawSVG:"100% 100%",
y:15
})
return tl;
}
function drawTick() {
var tl = new TimelineMax();
// draw tick
tl.fromTo('#tick',0.35,{
drawSVG:"61% 61%",
opacity:1,
immediateRender:false,
},
{
drawSVG:"100%",
opacity:1,
ease:Back.easeOut
},'draw')
.to('#dot',0.1,{
opacity:0
},'draw')
return tl;
}
masterTl.add(arrowOut())
.add(drawCircle(),0)
.add(throwDot(),'throwDot')
.add(drawLinesUp(),'throwDot+=0.05')
.add(drawTick())
.add(drawLinesDown(),'throwDot+=0.49')
// If the timeline has played all the way through restart the timeline on click
// else play the animation from the beginning
function PLayTimeline() {
if(masterTl.progress() == 1){
masterTl.restart()
} else {
masterTl.play()
}
}
// Play the animation on click
document.querySelector("#button").addEventListener("click", function(){
PLayTimeline()
});
/*
var tl = new TimelineMax({onStart: function(){
TweenMax.set("#tick",{opacity:0})
}
});
document.querySelector("#button").addEventListener("click", function(){
animateBtn()
});
function animateBtn() {
// checking the state of the timeline
changePlayBackDirection()
// arrow to 0
tl.to('#arrowGroup line',0.5,{
drawSVG:"0% 0%",
ease:Power4.easeIn
},'in')
// Animating the circle fill
.fromTo("#circleFill path",0.8,{
drawSVG:"0% 5%",
immediateRender:false
},
{
drawSVG:"100%",
ease:Sine.easeIn
},'in+=0.25')
.to("#circleFill",0.8,{
rotation:'-=360',
transformOrigin:"center center",
ease:Sine.easeIn
},'in+=0.25')
// throw dot
.to('#dot',0.01,{
opacity:1
})
.to('#dot',0.2,{
y:-100,
attr:{rx:2.5},
immediateRender:false,
ease:Circ.easeOut
},"ballUp")
.to('#dot',0.2,{
attr:{rx:4},
ease:Back.easeOut
},'ballUp+=0.2')
.to('#dot',0.25,{
attr:{ry:2.5},
y:-49,
immediateRender:false,
ease:Power4.easeIn
},'ballUp+=0.35')
// draw speed lines
.fromTo('#speedLines line',0.10,{
drawSVG:"20% 20%"
},{
drawSVG:"75%"
},'ballUp+=0.05')
.fromTo('#speedLines line',0.15,{
drawSVG:"75%",immediateRender:false
},{
drawSVG:"0% 0%",
y:0
},'ballUp+=0.15')
// draw tick
.fromTo('#tick',0.35,{
drawSVG:"61% 61%",
opacity:1,
immediateRender:false,
},
{
drawSVG:"100%",
opacity:1,
ease:Back.easeOut
},'draw')
.to('#dot',0.1,{
opacity:0
},'draw')
return tl.timeScale(1);
}
// Determine state
function changePlayBackDirection() {
if(tl.progress() == 1){
tl.restart()
} else {
tl.play()
}
}
*/
Also see: Tab Triggers