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.
<h2>Above and Below</h2>
<blockquote>
<p>“That every living thing stands in a fixed relationship to ‘above’ and ‘below’ and must without question remain that way, is a fact true also of the BP [Basic Plane] which, as such, is also a living thing. This can be partly explained as association or as transference of one’s own observations to the BP.</p>
<p>The ‘above’ gives the impression of a great looseness, a feeling of lightness, of emancipation and, finally, of freedom. […] The effect of ‘below’ is completely contrary: condensation, heaviness, constraint.</p>
<p>These characteristics of the upper and lower horizontal […] can be strengthened in a natural way for the purpose of ‘dramatization’ by means of a certain accumulation of heavier forms below and lighter ones above. Thereby the pressure, or, as the case may be, the tension, becomes considerably increased in both directions. </p>
<p>Vice versa, these characteristics can be partially equalized or, at least, modified – and, of course, through the use of the opposite means: heavier forms above, lighter ones below […].</p>
<p>These possibilities can be represented, purely schematically, as follows:”</p>
</blockquote>
<figure class="kandinsky">
<canvas class="basic-plane"></canvas>
<input type="range" id="inputRange" min="0.5" max="3.5" step="0.1" value="2">
<label for="inputRange">
<p>“Dramatization”</p>
<p>“Balance”</p>
<p>“Restraint”</p>
</label>
<figcaption>An implemention of Kandinsky’s algorithm – sound is added to emphasize the “characteristics of the upper and lower horizontal” </figcaption>
</figure>
<blockquote>“It can be assumed that in time, perhaps, means will be found of accomplishing measurements in the above sense with more or less exactness. At all events, the formula which I have just roughly outlined could be corrected in such a way that the relative nature of ‘balance’ would stand out with clarity. The means of measurement available to us are, however, exceedingly primitive. It is at present almost impossible for us to imagine how, for example, the weight of a scarcely visible point could be expressed by an exact number. The reason for this is that the concept ‘weight’ does not represent a material weight but is, rather, the expression of an inner force or, in our case, an inner tension.”</blockquote>
<hr>
<a href="https://monoskop.org/Wassily_Kandinsky#Publications">Kandinsky, W. (1947 [1926]). Point and line to plane. Contribution to the analysis of the pictorial elements. New York: Solomon R. Guggenheim Foundation, p. 116–117.</a>
.kandinsky {
align-items: center;
background: black;
color: white;
display: flex;
font-family: sans-serif;
justify-content: center;
padding: 5rem 0 6rem;
}
.kandinsky .basic-plane {
background: white;
border: 1px solid black;
}
.kandinsky figcaption {
margin-left: 2rem;
width: 20%;
}
.kandinsky input[type=range] {
transform: rotate(90deg);
width: 116px;
margin-left: -25px;
margin-right: -35px;
}
.kandinsky label {
color: grey;
display: flex;
flex-direction: column;
}
const Canvas = document.querySelector(".kandinsky .basic-plane");
Canvas.width = 222 * 1;
Canvas.height = 222 * 1.41;
const BasicPlane = Canvas.getContext("2d");
const InputRange = document.querySelector(".kandinsky input[type=range]");
// weight of form "below" -- is fixed!
var w0 = Canvas.width * 0.13;
var h0 = w0;
// center horizontally
var x0 = Canvas.width / 2;
// put at lower third vertically
var y0 = 2 * (Canvas.height / 3);
// set up sound
const audioCtx = new (window.AudioContext || window.webkitAudioContext)();
const osc0 = audioCtx.createOscillator("sine");
osc0.frequency.setValueAtTime(391, audioCtx.currentTime, 0.01);
const osc1 = audioCtx.createOscillator("triangle");
const gainNode = audioCtx.createGain();
osc0.connect(gainNode);
osc1.connect(gainNode);
gainNode.connect(audioCtx.destination);
gainNode.gain.value = 0.35;
var oscStarted = false;
// slider change …
InputRange.addEventListener("change", function (e) {
BasicPlane.clearRect(0, 0, Canvas.width, Canvas.height);
var dramaRatio = this.value;
var w1 = w0 * Math.sqrt(dramaRatio);
var h1 = w1;
// center horizontally
var x1 = Canvas.width / 2;
// put at upper quarter vertically
var y1 = Canvas.height / 4;
BasicPlane.filter = "blur(3px)";
BasicPlane.beginPath();
BasicPlane.arc(x0, y0 + w0 / 2, w0, 0, 2 * Math.PI);
BasicPlane.arc(x1, y1 + w1 / 2, w1, 0, 2 * Math.PI);
BasicPlane.fillStyle = "#333";
BasicPlane.fill();
if (oscStarted === false && e.isTrusted === true) {
osc0.start();
osc1.start();
oscStarted = true;
}
osc1.frequency.setValueAtTime(391 * (2 - dramaRatio / 2), audioCtx.currentTime, 0.01);
gainNode.gain.cancelScheduledValues(audioCtx.currentTime);
gainNode.gain.exponentialRampToValueAtTime(0.25, audioCtx.currentTime+1, 0.01);
gainNode.gain.exponentialRampToValueAtTime(0.001,audioCtx.currentTime + 4, 0.01);
});
// trigger silder event once, so that elements appear on canvas
const e = new Event("change");
InputRange.dispatchEvent(e);
function stopSound() {
InputRange.dispatchEvent(e);
}
Also see: Tab Triggers