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.
<!--
DRAWING A CUBIC BEZIER CURVE
This Pen shows how a computer renders a cubic bezier curve, as used in design and motion graphics programs. This Pen is part of an an article titled Mastering the Bezier Curve in Sketch.
~ Made by Peter Nowell @pnowelldesign, with help from Antoine and Julien Quint @graouts @pom
http://medium.com/@pnowelldesign/mastering-the-bezier-curve-in-sketch-4da8fdf0dbbb
-->
<svg width="550px" height="350px" viewBox="0 0 550 350" version="1.1" style="display:block; margin:100px auto 0 auto;">
<!-- Generator: Sketch 3.0.4 (8053) -->
<title>Cubic Bezier example</title>
<g id="Bezier-Curves" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<g id="Cubic-Bezier-example" transform="translate(-72.000000, -72.000000)">
<!-- Animate a circle radius from 0 to 1 to have the t parameter -->
<circle id="t" fill="none" stroke="none">
<animate attributeType="XML" attributeName="r" from="0" to="1" dur="7s" repeatCount="indefinite"/>
</circle>
<!--Main Curve -->
<path d="M100,400 C100,153 300,99.9999999 600,192" id="main-curve" stroke="#000000" stroke-width="2" fill-opacity="0.179206295" fill="#D8D8D8" stroke-dasharray="657.7994384765625" stroke-dashoffset="657.7994384765625">
<animate id="introMainCurve" attributeName="stroke-dashoffset" attributeType="XML" from="657.7994384765625" to="0" begin="0s" dur="7s" repeatCount="indefinite" calcMode="spline" keySplines="0.37 0.39 0.56 0.39" keyTimes="0;1" />
</path>
<!--Left Handle-->
<path d="M99,153.474639 L99,276.741808 L99,338.375393 L99,400.008977" id="left-handle" stroke="#5C60EC" stroke-width="2" stroke-linecap="square"></path>
<!--Right Handle-->
<path d="M299.938027,99.7211217 L374.703522,122.790841 L449.469018,145.860561 L599.000008,192" id="right-handle" stroke="#5C60EC" stroke-width="2" stroke-linecap="square"></path>
<!--Upper Dotted Line-->
<path d="M100,153.5 L150.124892,140.247525 L200.249783,126.99505 L300.499566,100.4901" id="upper-dotted-line" stroke="#979797" stroke-linecap="square" stroke-dasharray="1,3">
<animate id="introUpperDottedLine" attributeType="XML" attributeName="stroke-opacity" from="0" to="1" dur="1" begin="1s" />
<!--begin="one.begin+3s" dur="10s"-->
</path>
<!--Lower Dotted Line-->
<path d="M100,400 L600.501002,192.192116" id="lower-dotted-line" stroke="#979797" stroke-linecap="square" stroke-dasharray="1,3"></path>
<!--Cubic Drawing Triangle-->
<polyline stroke="#95cf29" stroke-width="2" id="triangle">
<animate attributeType="XML" attributeName="points" from="100,400 100,153 300,100" to="100,153 300,100 600,192" dur="7s" repeatCount="indefinite"/>
</polyline>
<!--Cubic Drawing Triangle-->
<path d="M100,400 L100,153 L300,100" id="cubic-drawing-triangle-50" stroke="#95CF29" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<animate id="special"
attributeName="d" attributeType="XML"
from="M100,400 L100,153 L300,100" to="M100,153 L300,100 L600,192"
begin="0s" dur="7s" repeatCount="indefinite"></animate>
</path>
<!-- Tangent line -->
<line stroke="#DE40CD" stroke-width="2" stroke-linecap="round" id="tangentLine"/>
<!--Tangent Point -->
<circle r="4" fill="#DE40CD" id="tangentPoint"/>
<!--Control Point Dots-->
<circle id="controlPoint1" cx="99" cy="154" r="4" fill="white" stroke="#5C60EC" stroke-width="2"></circle>
<circle id="controlPoint2" cx="301" cy="100" r="4" fill="white" stroke="#5C60EC" stroke-width="2"></circle>
<circle id="controlPoint0" cx="99" cy="400" r="4" fill="#5C60EC" stroke="#5C60EC" stroke-width="2"></circle>
<circle id="controlPoint0" cx="600" cy="192" r="4" fill="#5C60EC" stroke="#5C60EC" stroke-width="2"></circle>
</g>
</g>
</svg>
<!-- Link to the Article -->
<a href="http://medium.com/@pnowelldesign/mastering-the-bezier-curve-in-sketch-4da8fdf0dbbb" style="display:block; margin-top:80px; font-family:Avenir,Helvetica Neue,sans-serif; color:#9DAAC4; text-align:center;">(Part of the Article) Mastering the Bezier Curve in Sketch</a>
var circle = document.getElementById("t");
var poly = document.querySelector("polyline");
var tangentLine = document.getElementById("tangentLine");
var tangentPoint = document.getElementById("tangentPoint");
function animateTangent() {
if (poly.animatedPoints.numberOfItems == 0) {
requestAnimationFrame(animateTangent);
return;
}
var t = circle.r.animVal.value;
var u = 1 - t;
var p1 = poly.animatedPoints.getItem(0);
var p2 = poly.animatedPoints.getItem(1);
var p3 = poly.animatedPoints.getItem(2);
var x1 = p1.x * u + p2.x * t;
var y1 = p1.y * u + p2.y * t;
var x2 = p2.x * u + p3.x * t;
var y2 = p2.y * u + p3.y * t;
tangentLine.setAttribute("x1", x1);
tangentLine.setAttribute("y1", y1);
tangentLine.setAttribute("x2", x2);
tangentLine.setAttribute("y2", y2);
tangentPoint.setAttribute("cx", x1 * u + x2 * t);
tangentPoint.setAttribute("cy", y1 * u + y2 * t);
requestAnimationFrame(animateTangent);
}
requestAnimationFrame(animateTangent);
Also see: Tab Triggers