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.
<link href="https://fonts.googleapis.com/css2?family=Nunito+Sans:opsz,wght@6..12,400;6..12,800&display=swap" rel="stylesheet" />
<header class="header">
<h1 class="brand">
<span class="word">The</span> <span class="word">Agency</span>
<span class="word">of</span> <span class="word">Architecture</span>
</h1>
</header>
<article class="article">
<header class="title">
<span class="name">Foros</span>
<span class="description">School of Architecture</span>
<span class="year">2017</span>
</header>
<section class="lede">
<ul class="images">
<li class="image">
<canvas width="300" height="300"></canvas>
</li>
<li class="image">
<canvas width="300" height="300"></canvas>
</li>
<li class="image">
<canvas width="300" height="300"></canvas>
</li>
<li class="image">
<canvas width="300" height="300"></canvas>
</li>
<li class="image">
<canvas width="300" height="300"></canvas>
</li>
<li class="image">
<canvas width="300" height="300"></canvas>
</li>
<li class="image">
<canvas width="300" height="300"></canvas>
</li>
</ul>
</section>
<section class="main">
<p>
For sociologists and philosophers, agency is the capacity of an entity
to act in any given environment. In recent years, architecture has
been confronted with an ever changing social, economic, political and
built environment, thus the practice has been constantly challenged to
define, discuss and adapt its agency to respond in the most
appropriate way and become an instrument of charge.
</p>
<p>
The agency of architecture necessarily implies questioning the
relationship between theory and practice; and we are inevitably unable
to dissociate our work as architects from our personal behavior and
actions inasmuch as agency is also the capacity for human beings to
make choices, choices that affect our neighborhoods and even the
configuration of our cities. In this sense, the agency of architecture
can be understood as a catalyst for creating alternatives for the
built environment, and there are as many ways of doing so as there are
ways of practicing architecture: from research to urban interventions,
exhibitions and building.
</p>
<p>
This capacity of architecture to adapt, react and respond to specific
circumstances is visible in the work of practitioners from a diverse
set of backgrounds and projects. From small scale studios to big
offices, our aim is to give voice to those practices that constantly
seek to enrich, subvert or even put in crisis what we assume to be the
agency of architecture.
</p>
<p>
<span class="emphasis">Director of Foros:</span> Ethel Baraona<br />
Aula Magna School of Architecture<br />
Inmasulada 22, Barcelona<br />
<span class="emphasis">www.uic.es/architecture</span><br />
</p>
</section>
</article>
<aside class="sidebar">
<ul class="dates">
<div class="first">
<li class="date">
<span class="when">6 February</span>
<span class="who">Ines Weizman</span>
</li>
<li class="date">
<span class="when">20 February</span>
<span class="who">Ippolito Pestellini</span>
</li>
<li class="date">
<span class="when">6 March</span>
<span class="who">GOIG</span>
</li>
<li class="date">
<span class="when">20 March</span>
<span class="who">Markus Bader</span>
</li>
</div>
<div class="second">
<li class="date">
<span class="when">3 April</span>
<span class="who">Rafi Segal</span>
</li>
<li class="date">
<span class="when">24 February</span>
<span class="who">Maria Langarita</span>
</li>
<li class="date">
<span class="when">8 May</span>
<span class="who">Arno Brandlhuber</span>
</li>
</div>
</ul>
</aside>
<script type="x-shader/x-vertex">#version 300 es
#ifdef GL_FRAGMENT_PRECISION_HIGH
precision highp float;
#else
precision mediump float;
#endif
in vec2 position;
void main(void) {
gl_Position = vec4(position, 0., 1.);
}
</script>
<script type="x-shader/x-fragment">#version 300 es
/*********
* made by Matthias Hurrle (@atzedent)
*/
#ifdef GL_FRAGMENT_PRECISION_HIGH
precision highp float;
#else
precision mediump float;
#endif
out vec4 fragColor;
uniform vec2 resolution;
uniform float time;
#define T time
#define S smoothstep
#define rot(a) mat2(cos(a),-sin(a),sin(a),cos(a))
float box(vec3 p, vec3 s, float r) {
p = abs(p)-s;
return length(max(p, .0))+
min(.0, max(max(p.x, p.y), p.z))-r;
}
vec2 mod2(inout vec2 p, vec2 size) {
vec2 c = floor((p + size*.5)/size);
p = mod(p + size*.5,size) - size*.5;
return c;
}
float rep(vec3 p) {
p.xz += .5*T;
float d = 1E6;
vec2 n = mod2(p.xz, vec2(4.75,4));
p.y -= -1.75;
float sc = .8;
const float zz = 2.;
const float hh = 1.;
for (float i = .0; i < 3.; ++i) {
float dd = box(p, vec3(1, hh, 1.5), .05);
d = min(d, dd*sc);
p.xz = abs(p.xz);
p -= vec3(1, -hh*.25, 1);
p *= zz;
sc /= zz;
}
return d;
}
float map(vec3 p) {
float d1 = p.y+2.25;
float d2 = rep(p);
float d= d1;
d = min(d, d2);
return d;
}
vec3 norm(vec3 p) {
const float h = 1e-3;
const vec2 k = vec2(1,-1);
return normalize(
k.xyy*map(p+k.xyy*h) +
k.yyx*map(p+k.yyx*h) +
k.yxy*map(p+k.yxy*h) +
k.xxx*map(p+k.xxx*h)
);
}
float getshadow(vec3 ro, vec3 rd) {
const float steps=10., k=64.;
float shade=1.;
for(float i=1e-3;i<steps;) {
float d=map(ro+rd*i);
if(d<1e-3) {
shade=5e-3;
break;
}
shade=min(shade, k*d/i);
i+=d;
}
return shade;
}
float getao(vec3 p, vec3 n, float dist) {
return clamp(map(p+n*dist)/dist,.0,1.);
}
void main(void) {
float mn = min(resolution.x, resolution.y);
vec2 uv = (
gl_FragCoord.xy-.5*resolution
) / mn;
vec3 col = vec3(0),
ro = vec3(0,6,-6),
rd = normalize(vec3(uv, 1.5));
rd.yz*=rot(1.05);
rd.xz*=rot(.35);
vec3 p = ro;
const float steps = 20., maxd = 20.;
float dd = .0, bnz = .0;
for (float i = .0; i < steps; i++) {
float d = map(p);
if (d<1e-3) {
if (bnz > 1.) break;
vec3 n = norm(p),
r = reflect(rd, n),
l = normalize(vec3(2,4,-6)-p),
h = normalize(l-r);
float fog = 1.-clamp(dd/maxd, .0, 1.),
diff = max(.0, dot(l, n)),
fres = S(.0, 1., dot(-rd, n)),
shad = getshadow(p+n*5e-1,l),
ao=getao(p,n,.025);
col += mix(diff, fres, dot(h, n))*fog;
col *= shad+ao*1.5;
col = exp(log(col*2.));
col = pow(col, vec3(.4545))*fog;
rd = reflect(rd, n);
d = 3e-3;
p += rd+n*d;
}
if (dd>maxd) {
dd = maxd;
break;
}
p += rd * d;
dd += d;
}
vec2 z = (gl_FragCoord.xy-.5*resolution)/mn;
col *= S(1., .0, dot(z, z));
fragColor = vec4(col, 1);
}
</script>
<script type="x-shader/x-fragment">#version 300 es
/*********
* made by Matthias Hurrle (@atzedent)
*/
#ifdef GL_FRAGMENT_PRECISION_HIGH
precision highp float;
#else
precision mediump float;
#endif
out vec4 fragColor;
uniform vec2 resolution;
uniform float time;
uniform int scene;
const float PHI = (.5+.5*sqrt(5.));
const float INV_PHI = PHI-1.;
#define T time
#define S smoothstep
#define rot(a) mat2(cos(a),-sin(a),sin(a),cos(a))
#define plane(p,o,n) dot(p-o,n)
#define doubleplane(p,o,n) max(dot(p-o,n),dot(-p-o,n))
float box(vec3 p, vec3 s, float r) {
p = abs(p)-s;
return length(max(p, .0))+
min(.0, max(max(p.x, p.y), p.z))-r;
}
float sphere(vec3 p, float r) {
return length(p)-r;
}
float octahedron(vec3 p, float r) {
p = abs(p);
return (p.x+p.y+p.z-r)*.57735027;
}
float tetrahedron(vec3 p, float s) {
float n =1./sqrt(3.),
a = plane(p,vec3(s, s, s), vec3(-n,n,n)),
b = plane(p,vec3(s,-s,-s), vec3(n,-n,n)),
c = plane(p,vec3(-s,s,-s), vec3(n,n,-n)),
d = plane(p,vec3(-s,-s,s), vec3(-n,-n,-n));
return max(max(a,b),max(c,d));
}
float dodecahedron(vec3 p, float s) {
float
d=0.;
d=max(d,abs(dot(p,normalize(vec3(0,PHI,1)))));
d=max(d,abs(dot(p,normalize(vec3(0,-PHI,1)))));
d=max(d,abs(dot(p,normalize(vec3(1,0,PHI)))));
d=max(d,abs(dot(p,normalize(vec3(-1,0,PHI)))));
d=max(d,abs(dot(p,normalize(vec3(PHI,1,0)))));
d=max(d,abs(dot(p,normalize(vec3(-PHI,1,0)))));
return d-s;
}
float icosahedron(vec3 p, float s) {
float n=1./sqrt(3.);
vec3
a = n* vec3(1,1,1),
b = n* vec3(-1,1,1),
c = n* vec3(-1,1,-1),
d = n* vec3(1,1,-1),
e = n* vec3(0,INV_PHI,PHI),
f = n* vec3(0,INV_PHI,-PHI);
float dist = doubleplane(p,s*a,a);
dist = max(doubleplane(p,s*b,b),dist);
dist = max(doubleplane(p,s*c,c),dist);
dist = max(doubleplane(p,s*d,d),dist);
dist = max(doubleplane(p,s*e,e),dist);
dist = max(doubleplane(p,s*f,f),dist);
dist = max(doubleplane(p,s*e.zxy,e.zxy),dist);
dist = max(doubleplane(p,s*e.yzx,e.yzx),dist);
dist = max(doubleplane(p,s*f.zxy,f.zxy),dist);
dist = max(doubleplane(p,s*f.yzx,f.yzx),dist);
return dist;
}
float map(vec3 p) {
float d = 5e5,
flr = box(p+vec3(0,1.3,0),vec3(10,.1,10), .05),
obj;
if (scene == 0) obj = sphere(p, 1.);
else if (scene == 1) obj = dodecahedron(p, 1.);
else if (scene == 2) obj = octahedron(p, 1.);
else if (scene == 3) obj = tetrahedron(p, 1.);
else if (scene == 4) obj = sphere(p, 1.);
else if (scene == 5) obj = box(p, vec3(1.), .05);
else if (scene == 6) obj = icosahedron(p, 1.);
d = min(d, flr);
d = min(d, obj);
return d;
}
vec3 norm(vec3 p) {
vec2 e = vec2(1e-3, 0);
float d = map(p);
vec3 n = d - vec3(
map(p-e.xyy),
map(p-e.yxy),
map(p-e.yyx)
);
return normalize(n);
}
void cam(inout vec3 p) {
p.xz *= rot(T);
}
void main() {
vec2 uv = (
gl_FragCoord.xy-.5*resolution
) / min(resolution.x, resolution.y);
vec3 col = vec3(0),
ro = vec3(0, 0, -6),
rd = normalize(vec3(uv, 1)),
lpos = vec3(1,2,-3);
cam(ro);
cam(rd);
if (scene != 4) cam(lpos);
vec3 p = ro;
const float steps = 80., maxd = 20.;
float dd = .0, at = .0;
for (float i = .0; i<steps; i++) {
float d = map(p);
if (d < 1e-3) {
vec3 n = norm(p);
vec3 l = normalize(lpos-p);
float
fog = S(1., .0, i/80.),
diff = max(.0, dot(l, n));
col += diff*fog;
break;
}
if (dd > maxd) {
dd = maxd;
break;
}
p += rd*d;
dd += d;
at += .1*(.1/dd);
}
col += at;
fragColor = vec4(col, 1);
}
</script>
:root {
--bg: #007d0f94;
}
body {
display: grid;
position: relative;
grid-template-columns: repeat(2, 1fr);
grid-template-rows: 1fr auto 1fr;
gap: 2px;
margin: 0;
padding: 4rem 0;
background-color: #fefaef;
font-family: "Nunito Sans", sans-serif;
font-weight: 400;
font-size: 15px;
min-width: 610px;
}
.header {
display: contents;
}
.brand {
grid-row: 2;
grid-column: 1/-1;
justify-self: center;
align-self: center;
font-size: 3.1em;
text-transform: uppercase;
letter-spacing: 0.1em;
line-height: 1.1;
color: #fefaf0;
margin-bottom: 1.65em;
}
.brand .word {
display: block;
position: relative;
z-index: 10;
}
.brand .word:nth-of-type(odd) {
margin-left: 1ch;
}
.brand .word:nth-of-type(even) {
margin-left: 0.5ch;
}
.brand .word:nth-of-type(1):before {
content: "";
position: absolute;
left: -40px;
top: -40px;
width: 180px;
aspect-ratio: 1;
border-radius: 50%;
background: var(--bg);
z-index: -1;
}
.brand .word:nth-of-type(2) {
z-index: 10;
}
.brand .word:nth-of-type(2):before {
content: "";
position: absolute;
left: 101px;
top: -2px;
width: 130px;
height: 100px;
color: currentColor;
background: var(--bg);
z-index: -1;
}
.brand .word:nth-of-type(2):after {
content: "";
position: absolute;
left: 101px;
bottom: -107px;
width: 100px;
height: 60px;
color: currentColor;
background: var(--bg);
z-index: -1;
}
.brand .word:nth-of-type(3) {
z-index: 13;
}
.brand .word:nth-of-type(4) {
z-index: 12;
}
.brand .word:nth-of-type(4):before {
content: "";
position: absolute;
left: -33px;
top: -40px;
width: 140px;
aspect-ratio: 1;
border-radius: 50%;
background: var(--bg);
z-index: -1;
}
.brand .word:nth-of-type(4):after {
content: "";
position: absolute;
right: -21px;
top: -58px;
width: 160px;
aspect-ratio: 1;
border-radius: 50%;
background: var(--bg);
z-index: -1;
}
.article {
display: contents;
}
.article .title {
color: #74b475;
grid-row: 1;
grid-column: 1;
justify-self: end;
align-self: end;
margin-right: 80px;
margin-bottom: 0;
}
.article .title .name,
.article .title .year {
font-size: 2em;
font-weight: 800;
line-height: 0.8;
}
.article .title .description {
display: block;
width: 12ch;
text-transform: uppercase;
font-size: 1.1em;
font-weight: 800;
line-height: 0.95;
margin: 0.1em;
}
.sidebar {
display: contents;
}
.dates {
margin: 0;
padding: 0;
display: contents;
}
.dates .date {
display: block;
margin-bottom: 1em;
color: #74b475;
}
.dates .first {
grid-row: 1;
grid-column: 2;
align-self: end;
margin: 0 0 -33px 50px;
}
.dates .second {
grid-row: 3;
grid-column: 1;
justify-self: end;
margin-right: 20px;
}
.dates .date .when {
display: block;
font-size: 0.6em;
text-transform: uppercase;
}
.dates .date .who {
font-weight: 800;
}
.lede {
display: contents;
}
.images {
grid-row: 2;
grid-column: 1/-1;
margin: auto;
padding: 0;
z-index: -1;
display: grid;
grid-template-columns: repeat(12, 50px);
grid-template-rows: repeat(7, 50px);
gap: 1px;
min-width: 300px;
min-height: 350px;
}
.images .image {
display: block;
background: #d4d1ca;
}
.images .image:nth-of-type(1) {
grid-row: 4/6;
grid-column: 3/5;
}
.images .image:nth-of-type(2) {
grid-row: 1/3;
grid-column: 5/7;
}
.images .image:nth-of-type(3) {
grid-row: 3/5;
grid-column: 5/7;
}
.images .image:nth-of-type(4) {
grid-row: 5/7;
grid-column: 5/7;
}
.images .image:nth-of-type(5) {
grid-row: 4/6;
grid-column: 7/9;
}
.images .image:nth-of-type(6) {
position: relative;
grid-row: 6/8;
grid-column: 7/9;
}
.images .image:nth-of-type(7) {
grid-row: 3/5;
grid-column: 9/11;
}
.images .image:nth-of-type(6)::after {
content: "";
position: absolute;
inset: 0;
background: var(--bg);
}
.images .image canvas {
width: 100px;
height: 100px;
}
.article .main {
columns: 100px 2;
font-size: 0.4em;
grid-row: 3;
grid-column: 2;
margin: 2em 0 0 0;
max-width: 220px;
}
.article .main > p {
margin-top: 0;
}
.emphasis {
font-weight: 800;
}
/*********
* made by Matthias Hurrle (@atzedent)
*/
const dpr = Math.min(1,.5*window.devicePixelRatio)
function render() {
const fragmentShaders = [...document.querySelectorAll(
'script[type="x-shader/x-fragment"]'
)]
const vertexShader = document.querySelector(
'script[type="x-shader/x-vertex"]'
).innerHTML
const canvases = document.querySelectorAll("canvas")
function* choose() {
let i = 0
yield fragmentShaders.shift()
while (true) {
yield fragmentShaders[i]
i = (i + 1) % fragmentShaders.length
}
}
const getNextShader = choose()
let canvasIndex = 0
for (let canvas of canvases) {
const cvidx = canvasIndex++
canvas.width *= dpr
canvas.height *= dpr
const gl = canvas.getContext("webgl2")
const fragmentShader = getNextShader.next().value.innerHTML
let time
let buffer
let program
let resolution
let scene
let vertices = []
setup()
draw()
function compile(shader, source) {
gl.shaderSource(shader, source)
gl.compileShader(shader)
if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
console.error(gl.getShaderInfoLog(shader))
}
}
function setup() {
const vs = gl.createShader(gl.VERTEX_SHADER)
const fs = gl.createShader(gl.FRAGMENT_SHADER)
program = gl.createProgram()
compile(vs, vertexShader)
compile(fs, fragmentShader)
gl.attachShader(program, vs)
gl.attachShader(program, fs)
gl.linkProgram(program)
if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {
console.error(gl.getProgramInfoLog(program))
}
vertices = [
-1.0, -1.0, 1.0, -1.0, -1.0, 1.0, -1.0, 1.0, 1.0, -1.0, 1.0, 1.0,
]
buffer = gl.createBuffer()
gl.bindBuffer(gl.ARRAY_BUFFER, buffer)
gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(vertices), gl.STATIC_DRAW)
const position = gl.getAttribLocation(program, "position")
gl.enableVertexAttribArray(position)
gl.vertexAttribPointer(position, 2, gl.FLOAT, false, 0, 0)
time = gl.getUniformLocation(program, "time")
resolution = gl.getUniformLocation(program, "resolution")
scene = gl.getUniformLocation(program, "scene")
}
function draw(now) {
gl.clearColor(0, 0, 0, 1)
gl.clear(gl.COLOR_BUFFER_BIT)
gl.useProgram(program)
gl.bindBuffer(gl.ARRAY_BUFFER, null)
gl.bindBuffer(gl.ARRAY_BUFFER, buffer)
gl.uniform1f(time, now * 0.001)
gl.uniform2f(resolution, canvas.width, canvas.height)
gl.uniform1i(scene, cvidx)
gl.drawArrays(gl.TRIANGLES, 0, vertices.length * 0.5)
requestAnimationFrame(draw)
}
}
}
function main() {
render()
}
document.body.onload = main
Also see: Tab Triggers