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="slider"></div> -->
<div class="container">
<svg class="circ-graph" id="circ-graph" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 750 500">
<defs>
<filter id="goo" color-interpolation-filters="sRGB">
<feGaussianBlur in="SourceGraphic" stdDeviation="6" result="blur" />
<feColorMatrix in="blur" mode="matrix" values="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 18 -7" result="goo" />
<feBlend in="SourceGraphic" in2="goo" />
</filter>
</defs>
<g id="base-lines" opacity="0.18" fill="none" stroke="#fff" stroke-miterlimit="10" stroke-width="25">
<path d="M430.5,250A55.5,55.5,0,1,1,375,194.5" />
<path d="M470.5,250A95.5,95.5,0,1,1,375,154.5" />
<path d="M510.5,250A135.5,135.5,0,1,1,375,114.5" />
<path d="M550.5,250A175.5,175.5,0,1,1,375,74.5" />
<path d="M590.5,250C590.5,369,494,465.5,375,465.5S159.5,369,159.5,250,256,34.5,375,34.5" />
</g>
<g id="mid-lines" opacity="0.44" fill="none" stroke="#fff" stroke-miterlimit="10" stroke-width="4">
<path d="M445,250a70,70,0,1,1-70-70" />
<path d="M485,250A110,110,0,1,1,375,140" />
<path d="M525,250A150,150,0,1,1,375,100" />
<path d="M565,250c0,104.93-85.07,190-190,190S185,354.93,185,250,270.07,60,375,60" />
<path d="M605,250c0,127-103,230-230,230S145,377,145,250,248,20,375,20" />
</g>
<g id="top-lines" fill="none" stroke="#fff" stroke-miterlimit="10" stroke-width="4">
<path class="line0 line" d="M375,180a70,70,0,1,0,70,70" />
<path class="line1 line" d="M375,140A110,110,0,1,0,485,250" />
<path class="line2 line" d="M375,100A150,150,0,1,0,525,250" />
<path class="line3 line" d="M375,60c-104.93,0-190,85.07-190,190s85.07,190,190,190,190-85.07,190-190" />
<path class="line4 line" d="M375,20C248,20,145,123,145,250S248,480,375,480,605,377,605,250" />
</g>
<g id="horz-lines" fill="none" stroke="#fff" stroke-miterlimit="10" stroke-width="4">
<line x1="375" y1="180" x2="456" y2="180" />
<line x1="375" y1="140" x2="456" y2="140" />
<line x1="375" y1="100" x2="456" y2="100" />
<line x1="375" y1="60" x2="456" y2="60" />
<line x1="375" y1="20" x2="456" y2="20" />
</g>
<g id="people">
<g class="person">
<text class="job-title serif" transform="translate(484 201.09)">US Correspondent, RTE</text>
<text class="twitter-handle sans-semi" transform="translate(615 184.1)">@caitrionaperry</text>
<text class="person-name sans-semi" transform="translate(484 183.09)">CAITRIONA PERRY</text>
</g>
<g class="person">
<text class="job-title serif" transform="translate(484 161.09)">Columnist/Presenter, Irish Times/RTE</text>
<text class="twitter-handle sans-semi" transform="translate(566 142.09)">@kenearlys</text>
<text class="person-name sans-semi" transform="translate(484 142.09)">KEN EARLY</text>
</g>
<g class="person">
<text class="job-title serif" transform="translate(484 120.09)">Editor, Richard Oakley</text>
<text class="twitter-handle sans-semi" transform="translate(612 101.09)">@roakleyst</text>
<text class="person-name sans-semi" transform="translate(484 101.09)">RICHARD OAKLEY</text>
</g>
<g class="person">
<text class="job-title serif" transform="translate(484 80.09)">Deputy Business Editor, Irish Times</text>
<text class="twitter-handle sans-semi" transform="translate(604 61.09)">@ITdominiccoyle</text>
<text class="person-name sans-semi" transform="translate(484 61.09)">DOMINIC COYLE</text>
</g>
<g class="person">
<text class="job-title serif" transform="translate(484 40.1)">Columnist, Sunday Independent</text>
<text class="twitter-handle sans-semi" transform="translate(583 21.1)">@carolmhunt</text>
<text class="person-name sans-semi" transform="translate(484 21.1)">CAROL HUNT</text>
</g>
</g>
<g class="goo" filter="url(#goo)">
<g id="circles" fill="#fff" >
<circle id="circ4" class="circ4 circ" cx="375" cy="20" r="15" />
<circle class="circ3 circ" cx="375" cy="60" r="15" />
<circle class="circ2 circ" cx="375" cy="100" r="15" />
<circle class="circ1 circ" cx="375" cy="140" r="15" />
<circle class="circ0 circ" cx="375" cy="180" r="15" />
</g>
<circle id="center-circ" cx="375" cy="250" r="30.5" fill="#fff" />
</g>
<text id="gain" class="sans-semi" transform="translate(356.43 255)" font-size="15" fill="#7b5ba3">GAIN</text>
<text class="value"></text>
<text class="value"></text>
<text class="value"></text>
<text class="value"></text>
<text class="value"></text>
</svg>
</div>
<div class="me">
<a class="me__link portfolio" href="http://www.petebarr.com" target='_blank'>Petebarr.com<span></span></a>
</div>
<a class="twitter" href="https://twitter.com/petebarr" target='_blank'>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 52 52">
<path fill="#fff" d="M39.19 15.39a10.63 10.63 0 0 1-3.38 1.29 5.31 5.31 0 0 0-9.19 3.63 5.43 5.43 0 0 0 .14 1.22A15.11 15.11 0 0 1 15.8 16a5.39 5.39 0 0 0-.72 2.68 5.32 5.32 0 0 0 2.37 4.42 5.33 5.33 0 0 1-2.45-.7v.07a5.31 5.31 0 0 0 4.27 5.21 5.45 5.45 0 0 1-1.41.19 4.78 4.78 0 0 1-1-.1 5.32 5.32 0 0 0 5 3.69 10.64 10.64 0 0 1-6.6 2.28c-.43 0-.85 0-1.27-.07a15.13 15.13 0 0 0 23.28-12.74v-.69a10.87 10.87 0 0 0 2.66-2.75 10.84 10.84 0 0 1-3.06.84 5.35 5.35 0 0 0 2.34-2.94"></path>
<!-- <path fill="#fff" d="M26 5A21 21 0 1 1 5 26 21 21 0 0 1 26 5m0-4a25 25 0 1 0 25 25A25 25 0 0 0 26 1z"></path> -->
</svg>
</a>
body {
background-color:#4285F4;
background: linear-gradient(to right, #ed30a0 0%,#0b86a6 100%);
}
body,
html {
height: 100%;
width: 100%;
margin: 0;
padding: 0;
}
#slider{
width:300px;
position:relative;
margin: 30px auto;
}
.container {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 750px;
height: 500px;
}
svg {
width: 100%;
height: 100%;
visibility: hidden;
}
#circ {
fill: white;
}
#base-lines, #mid-lines, #top-lines {
path {
stroke: white;
}
}
#base-lines {
opacity: 0.18;
}
#mid-lines {
opacity: 0.44;
}
#top-lines {
opacity: 1;
}
.person {
font-size: 14px;
}
.sans-semi {
font-family: "open-sans",sans-serif;
font-weight: 600;
font-style: normal;
}
.serif {
font-family: "ff-meta-serif-web-pro",serif;
font-weight: 500;
font-style: normal;
}
.person-name {
fill: white;
}
.twitter-handle {
fill: white;
}
.job-title {
fill: "#003241";
}
.value {
opacity: 0;
@extend .sans-semi;
font-size: 12px;
fill: #7b5ba3;
}
.me {
position: fixed;
z-index: 1000;
top: 24px;
left: 24px;
display: flex;
flex-direction: column;
}
.me__link {
position: relative;
margin-bottom: 16px;
color: white;
font-family: Helvetica, sans-serif;
text-decoration: none;
font-size: 16px;
span {
display: block;
position: absolute;
bottom: -3px;
left: 0;
height: 1px;
width: 5%;
background-color: white;
content: "";
transition: width 0.3s;
}
&:hover span{
width: 100%;
}
}
.twitter {
position: fixed;
top: 16px;
right: 24px;
display: block;
width: 40px;
height: 40px;
}
@media (max-width: 768px) {
.twitter {
position: fixed;
top: 48px;
right: auto;
left: 14px;
}
}
TweenMax.set('svg', {
visibility: 'visible'
});
TweenMax.set('#center-circ', {
transformOrigin: '50% 50%'
});
TweenMax.set(['#base-lines path','#mid-lines path','#top-lines path'], {
drawSVG:'0% 0%'
});
TweenMax.set('.circ', {
opacity: 0,
xPercent:-50,
yPercent:-50,
x: 15,
y: 15
})
/* ==========================================================================
GLOBAL VARIABLES
========================================================================== */
var total = 218;
var vals = [117, 131, 143, 191, 218];
var percs;
var baseTime = 0.7;
/* Cached jQuery objects */
var values = $(".value");
var circs = $(".circ");
/* ==========================================================================
FUNCTIONS
========================================================================== */
function initPercs() {
percs = [];
for(i=0; i<vals.length; i++) {
percs.push(100*vals[i]/218);
}
};
function setValues() {
var tempVals = vals.reverse();
for(i=0; i<values.length; i++) {
values[i].textContent = Math.round(tempVals[i]);
}
};
function positionValues() { // called oncomplete of last circ
for(i=0; i<values.length; i++) {
var newText = values[i];
newText.setAttributeNS(null,"x",circs[i]._gsTransform.x + circs[i]._gsTransform.xOrigin - 10);
newText.setAttributeNS(null,"y",circs[i]._gsTransform.y + circs[i]._gsTransform.yOrigin + 5);
}
};
initPercs();
setValues();
/* ==========================================================================
TIMELINE
========================================================================== */
var tl = new TimelineMax({repeat: 2, repeatDelay: 2});
//var percs = [53, 60, 66, 85, 100];
var linesPerc = ["0% "+percs[0]+"%", "0% "+percs[1]+"%", "0% "+percs[2]+"%", "0% "+percs[3]+"%", "0% "+percs[4]+"%"];
var motionPath0 = MorphSVGPlugin.pathDataToBezier(".line0", {align:".circ0"});
var bezierTween0 = TweenMax.to(".circ0", 1, {bezier:{values: motionPath0, type: "cubic"}, ease:Linear.easeNone}).pause();
var percent0 = percs[0]/100;
var motionPath1 = MorphSVGPlugin.pathDataToBezier(".line1", {align:".circ1"});
var bezierTween1 = TweenMax.to(".circ1", 1, {bezier:{values: motionPath1, type: "cubic"}, ease:Linear.easeNone}).pause();
var percent1 = percs[1]/100;
var motionPath2 = MorphSVGPlugin.pathDataToBezier(".line2", {align:".circ2"});
var bezierTween2 = TweenMax.to(".circ2", 1, {bezier:{values: motionPath2, type: "cubic"}, ease:Linear.easeNone}).pause();
var percent2 = percs[2]/100;
var motionPath3 = MorphSVGPlugin.pathDataToBezier(".line3", {align:".circ3"});
var bezierTween3 = TweenMax.to(".circ3", 1, {bezier:{values: motionPath3, type: "cubic"}, ease:Linear.easeNone}).pause();
var percent3 = percs[3]/100;
var motionPath4 = MorphSVGPlugin.pathDataToBezier(".line4", {align:".circ4"});
var bezierTween4 = TweenMax.to(".circ4", 1, {bezier:{values: motionPath4, type: "cubic"}, ease:Linear.easeNone}).pause();
var percent4 = percs[4]/100;
tl.fromTo('#center-circ', baseTime, { scale: 0 }, {
scale: 1,
delay: 0.2,
ease: Elastic.easeOut.config(0.5, 0.4)
}, 0.15)
.fromTo('#gain', 0.3, {
opacity:0 }, {
opacity:1,
ease: Linear.easeNone
}, "-=0.5")
.set('.circ', {opacity: 1}, "-=0.6")
.staggerFrom('.circ', baseTime*3, {
cycle: {
y: function(i) { return 235-i*40; }
},
ease: Power3.easeInOut
}, 0.15, "-=0.8")
.staggerTo('#base-lines path', baseTime, {
drawSVG: '0% 100%',
ease: Power2.easeInOut
}, 0.15, "-=1.3")
.staggerTo('#mid-lines path', baseTime, {
drawSVG: '0% 100%',
ease: Power2.easeInOut
}, 0.15, "-=1.1")
.staggerTo('#top-lines path', baseTime*2, {
cycle: {
drawSVG: function(i) { return linesPerc[i]; }
},
ease: Power3.easeInOut
}, 0.15, "-=0.3")
.staggerFromTo('#horz-lines line', baseTime/2, {
scaleX:0 }, {
scaleX: 1,
ease: Power2.easeOut
}, 0.15, "-=2.4")
.staggerFromTo('.person', baseTime/2, {
opacity:0, x:20 }, {
opacity: 1, x:0,
ease: Power2.easeOut
}, 0.1, "-=2.2")
.set('.circ', {opacity: 1}, "-=2")
.to(bezierTween0, baseTime*2, {progress:percent0, ease:Power3.easeInOut}, "-=2")
.to(bezierTween1, baseTime*2, {progress:percent1, ease:Power3.easeInOut}, "-=1.85")
.to(bezierTween2, baseTime*2, {progress:percent2, ease:Power3.easeInOut}, "-=1.7")
.to(bezierTween3, baseTime*2, {progress:percent3, ease:Power3.easeInOut}, "-=1.55")
.to(bezierTween4, baseTime*2, {progress:percent4, ease:Power3.easeInOut, onComplete: positionValues }, "-=1.4")
//.set('.value', { xPercent: -50, yPercent: -50 }) // ??
.to('.value', 0.5, {opacity:1, ease: Linear.easeNone});
/* ==========================================================================
SLIDER
========================================================================== */
var $slider = $('#slider'),
sliderValue = { value: 0 };
$slider.slider({
range: false,
min: 0,
max: 100,
step: .1,
start: function() {
tl.pause();
},
slide: function(event, ui) {
tl.progress(ui.value / 100);
},
stop: function() {
tl.play();
}
});
tl.eventCallback("onUpdate", function() {
sliderValue.value = tl.progress() * 100;
$slider.slider(sliderValue);
});
Also see: Tab Triggers