dieren: constant cell width for any gallery table
authorMischa POSLAWSKY <perl@shiar.org>
Mon, 14 Feb 2022 17:09:14 +0000 (18:09 +0100)
committerMischa POSLAWSKY <perl@shiar.org>
Tue, 1 Mar 2022 20:22:00 +0000 (21:22 +0100)
Common styling without percentage hints, replacing table elements by grid
columns with something resembling 1fr widths.

base.css
dieren.plp

index 8738378e6ce724036f8535ba991fcf4817d70f52..dab95d708c53d3ce7bf3e5eccd693ada49316764 100644 (file)
--- a/base.css
+++ b/base.css
@@ -741,10 +741,33 @@ img {
        background: rgba(0, 0, 0, .5);
 }
 
+/* specialised galleries */
+
 body#word {
        margin: 8px 1px;
 }
 
+table.gallery {
+       grid-auto-flow: row;
+       grid-template-columns: repeat(auto-fit, minmax(2em, max-content)); /* 1fr */
+}
+table.gallery tbody,
+table.gallery tr {
+       display: contents;
+}
+table.gallery tr > :first-child {
+       grid-column: 1;
+       -grid-row: span 6;
+       margin: auto; /* vertical-align: middle */
+}
+table.gallery tr > :nth-child(2) {
+       grid-column: 2; /* in case 1st is missing */
+}
+table.gallery td {
+       border: 0; /* does not collapse */
+       outline: 1px solid #888; /* over grid-gap */
+}
+
 /* page-specific */
 
 #browser td > a {
index 477f3ac191c924f9841712be84aeb690dd3ded8e..8abcdfdbd28835213669fe1cfe6c3679d5ecf2d5 100644 (file)
@@ -39,30 +39,21 @@ Html({
        '],
        raw => <<'EOT',
 <style>
-table {
-       width: 100%;
-}
-th {
-       width: 1%; /* min-content */
-}
-td {
-       width: 15%; /* 1fr */
-       vertical-align: top;
-}
 figure[hidden] {
+       opacity: 0; /* secret */
        transition: opacity 1s 0s;
-       display: inline;
-       opacity: 0;
+       display: block;
 }
 figure[hidden]:hover {
        opacity: 1;
        transition-delay: 1s;
 }
+figure[hidden]:hover > figcaption {
+       transition-delay: 2s;
+}
 
 @media (max-width: 60em) {
-       figcaption {
-               position: static;
-               padding: 0;
+       td, th {
                font-size: 50%;
        }
        figcaption small {
@@ -71,9 +62,6 @@ figure[hidden]:hover {
        th:first-child {
                display: none;
        }
-       th {
-               font-size: 50%;
-       }
 }
 </style>
 EOT
@@ -148,7 +136,7 @@ if (exists $get{r}) {
        }
 }
 
-say '<table>';
+say '<table class="gallery">';
 while (my $name = shift @table) {
        if ($name =~ s/^#// and !$pageinfo->{prefix}) {
                while ($name = shift @table) {