diff --git a/castle.jpg b/castle.jpg new file mode 100644 index 0000000..a4addc9 Binary files /dev/null and b/castle.jpg differ diff --git a/index.css b/index.css index e1b6f11..6874acb 100644 --- a/index.css +++ b/index.css @@ -1,7 +1,7 @@ :root { --font-family: "Fira Code", monospace; --line-height: 1.25rem; - --border-thickness: 1.5px; + --border-thickness: 1px; --bold-weight: 700; font-family: var(--font-family); @@ -41,7 +41,7 @@ body { width: 100%; margin: 0; padding: var(--line-height) 2ch; - max-width: 80ch; + max-width: calc(min(80ch, round(down, 100%, 1ch))); line-height: var(--line-height); } @@ -165,6 +165,23 @@ p { hyphens: auto; } +img { + --real-height: 100% / var(--ratio); + + display: block; + width: 100%; + padding-bottom: calc( + round( + down, + var(--line-height) - ( + var(--real-height) - round(down, var(--real-height), var(--line-height)) + ), + 1px + ) + ); + object-fit: contain; +} + pre, code { font-family: var(--font-family); } diff --git a/index.js b/index.js new file mode 100644 index 0000000..89ac20c --- /dev/null +++ b/index.js @@ -0,0 +1,12 @@ +// Set the ratio variable on each image. +document.querySelectorAll("img").forEach(img => { + function onLoaded() { + const ratio = img.naturalWidth / img.naturalHeight; + img.style.setProperty("--ratio", ratio); + } + if (img.loaded) { + onLoaded(); + } else { + img.addEventListener("load", onLoaded); + } +}); diff --git a/index.md b/index.md index 60694a6..5bec1fb 100644 --- a/index.md +++ b/index.md @@ -141,3 +141,7 @@ Let's go wild and draw a chart! 0 └───▀─────────▀─────────▀──────────▀───────────── Socks Jeans Shirts USB Drives + +## Images + +![A room in an old French castle.](castle.jpg) diff --git a/template.html b/template.html index ad9aefb..12ae3f1 100644 --- a/template.html +++ b/template.html @@ -67,5 +67,6 @@ $for(include-after)$ $include-after$ $endfor$
+