mirror of
https://github.com/frainfreeze/the-monospace-web-pandoc
synced 2025-12-29 18:49:50 -08:00
support images
This commit is contained in:
BIN
castle.jpg
Normal file
BIN
castle.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.5 MiB |
21
index.css
21
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);
|
||||
}
|
||||
|
||||
12
index.js
Normal file
12
index.js
Normal file
@@ -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);
|
||||
}
|
||||
});
|
||||
4
index.md
4
index.md
@@ -141,3 +141,7 @@ Let's go wild and draw a chart!
|
||||
0 └───▀─────────▀─────────▀──────────▀─────────────
|
||||
Socks Jeans Shirts USB Drives
|
||||
</pre></figure>
|
||||
|
||||
## Images
|
||||
|
||||

|
||||
|
||||
@@ -67,5 +67,6 @@ $for(include-after)$
|
||||
$include-after$
|
||||
$endfor$
|
||||
<div class="grid"></div>
|
||||
<script src="index.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user