diff --git a/index.css b/index.css
index 1ad5c9e..c4bba9c 100644
--- a/index.css
+++ b/index.css
@@ -30,10 +30,6 @@
}
-*:first-child {
- margin: 0;
-}
-
* + * {
margin-top: var(--line-height);
}
@@ -69,13 +65,14 @@ body {
h1, h2, h3, h4, h5, h6 {
font-weight: var(--bold-weight);
- margin: calc(var(--line-height) * 2) 0 0;
+ margin: calc(var(--line-height) * 2) 0 var(--line-height);
line-height: var(--line-height);
}
h1 {
font-size: 2rem;
line-height: calc(2 * var(--line-height));
+ margin-bottom: calc(var(--line-height) * 2);
text-transform: uppercase;
}
h2 {
@@ -111,7 +108,7 @@ a:link, a:visited {
}
p {
- margin-top: var(--line-height);
+ margin-bottom: var(--line-height);
}
strong {
@@ -136,7 +133,7 @@ table {
top: calc(var(--line-height) / 2);
width: calc(round(down, 100%, 1ch));
border-collapse: collapse;
- margin: var(--line-height) 0 calc(var(--line-height) * 3);
+ margin: 0 0 calc(var(--line-height) * 2);
}
th, td {
@@ -168,6 +165,9 @@ th {
.header {
margin-bottom: calc(var(--line-height) * 2);
}
+.header h1 {
+ margin: 0;
+}
.header tr td:last-child {
text-align: right;
}
@@ -184,11 +184,12 @@ img, video {
display: block;
width: 100%;
padding-bottom: calc(
- round(
- nearest,
- round(up, var(--real-height), var(--line-height)) - var(--real-height),
- 1px
- )
+ round(
+ up,
+ var(--real-height),
+ var(--line-height)
+ )
+ - var(--real-height)
);
object-fit: contain;
}
@@ -196,10 +197,13 @@ img, video {
details {
border: var(--border-thickness) solid var(--text-color);
padding: calc(var(--line-height) - var(--border-thickness)) 1ch;
+ margin-bottom: var(--line-height);
}
summary {
font-weight: 600;
+}
+details[open] summary {
margin-bottom: var(--line-height);
}
@@ -208,6 +212,9 @@ details ::marker {
content: '►';
margin: 0;
}
+details[open] ::marker {
+ content: '▼';
+}
details :last-child {
margin-bottom: 0;
@@ -216,6 +223,10 @@ details :last-child {
pre {
white-space: pre;
overflow-x: auto;
+ margin: var(--line-height) 0;
+}
+figure pre {
+ margin: 0;
}
pre, code {
@@ -239,7 +250,7 @@ figcaption {
ul, ol {
padding: 0;
- margin: var(--line-height) 0;
+ margin: 0 0 var(--line-height);
}
ul {
@@ -251,8 +262,12 @@ ol {
counter-reset: item;
padding: 0;
}
-ol ol {
+ol ul,
+ol ol,
+ul ol,
+ul ul {
padding: 0 0 0 3ch;
+ margin: 0;
}
ol li:before {
content: counters(item, ".") ". ";
@@ -395,6 +410,7 @@ label input {
display: flex;
gap: 1ch;
width: calc(round(down, 100%, (1ch * var(--grid-cells)) - (1ch * var(--grid-cells) - 1)));
+ margin-bottom: var(--line-height);
}
.grid > *,
diff --git a/index.html b/index.html
index ba59228..43d2b1d 100644
--- a/index.html
+++ b/index.html
@@ -5,7 +5,7 @@
-
+
The Monospace Web
@@ -25,7 +25,7 @@
| Updated |
- 2024-08-30 |
+ 2024-08-26 |
| Author |
@@ -104,7 +104,9 @@ Hidden gems.
tree class:
-
-
/dev/nvme0n1p2
+
+/dev/nvme0n1p2
+
- usr
@@ -139,8 +141,7 @@ Hidden gems.
- run
-- tmp
-
+- tmp
diff --git a/index.js b/index.js
index 426131d..52b58c3 100644
--- a/index.js
+++ b/index.js
@@ -4,6 +4,17 @@ function firstEvent(element, name) {
});
}
+function gridCellDimensions() {
+ const element = document.createElement("div");
+ element.style.position = "fixed";
+ element.style.height = "var(--line-height)";
+ element.style.width = "1ch";
+ document.body.appendChild(element);
+ const rect = element.getBoundingClientRect();
+ document.body.removeChild(element);
+ return { width: rect.width, height: rect.height };
+}
+
const defaultRatio = 16/9;
// Set the ratio variable on each media.
@@ -17,13 +28,13 @@ function setRatios() {
ratio = media.naturalWidth / media.naturalHeight;
break;
case "VIDEO":
- if (media.videoWidth != 0 && media.videoHeight != 0) {
- ratio = media.videoWidth / media.videoHeight;
- }
+ ratio = media.videoWidth / media.videoHeight;
break;
}
- console.log("Setting ratio", ratio, "for element", media);
- media.style.setProperty("--ratio", ratio);
+ if (ratio != NaN) {
+ console.log("Setting ratio", ratio, "for element", media);
+ media.style.setProperty("--ratio", ratio);
+ }
}
switch (media.tagName) {
case "IMG":
@@ -48,12 +59,30 @@ function setRatios() {
setRatios();
function checkOffsets() {
+ const ignoredTagNames = new Set([
+ "THEAD",
+ "TBODY",
+ "TFOOT",
+ "TR",
+ "TD",
+ "TH",
+ ]);
+ const cell = gridCellDimensions();
const elements = document.querySelectorAll("body :not(.debug-grid, .debug-toggle)");
for (const element of elements) {
- const offset = element.offsetTop % 10;
- if(element.offsetParent == document.body && offset > 0) {
+ if (ignoredTagNames.has(element.tagName)) {
+ continue;
+ }
+ const rect = element.getBoundingClientRect();
+ if (rect.width === 0 && rect.height === 0) {
+ continue;
+ }
+ const top = rect.top + window.scrollY;
+ const left = rect.left + window.scrollX;
+ const offset = top % (cell.height / 2);
+ if(offset > 0) {
element.classList.add("off-grid");
- console.error("Incorrect vertical offset:", element, element.offsetTop % 20);
+ console.error("Incorrect vertical offset for", element, "with remainder", top % cell.height, "when expecting divisible by", cell.height / 2);
} else {
element.classList.remove("off-grid");
}
diff --git a/index.md b/index.md
index 6446585..a4ba2d9 100644
--- a/index.md
+++ b/index.md
@@ -2,7 +2,7 @@
title: The Monospace Web
subtitle: A minimalist design exploration
author: Oskar Wickström
-date: 2024-08-30
+date: 2024-08-26
lang: en
toc-title: Contents
version: v0.1.0
@@ -64,10 +64,7 @@ Ordered lists look pretty much as you'd expect:
It's nice to visualize trees.
This is a regular unordered list with a `tree` class:
-
--
-
-**/dev/nvme0n1p2**
+
/dev/nvme0n1p2
* usr
* local
@@ -87,8 +84,8 @@ This is a regular unordered list with a `tree` class:
* media
* run
* tmp
-
-
+
+
## Tables