1
0
Fork 0
mirror of https://git.sr.ht/~seirdy/seirdy.one synced 2024-11-27 14:12:09 +00:00

More containment, alignment fixes

This commit is contained in:
Rohan Kumar 2022-08-01 20:51:12 -07:00
parent 2bdcd17970
commit c949089676
No known key found for this signature in database
GPG key ID: 1E892DB2A5F84479

View file

@ -57,7 +57,7 @@ html {
* 108.75% is the minimum required to get superscripts to reach 14.5 * 108.75% is the minimum required to get superscripts to reach 14.5
* CSS pixels with most default stylesheets. At that size, my dark * CSS pixels with most default stylesheets. At that size, my dark
* color palette has sufficient contrast.*/ * color palette has sufficient contrast.*/
font-size: 108.75%; font-size: 109%;
/* Aligning to the center with space on both sides prevents accidental /* Aligning to the center with space on both sides prevents accidental
* link activation on tablets, and is a common practice that users are * link activation on tablets, and is a common practice that users are
@ -67,8 +67,8 @@ html {
/* WCAG recommends a max line width. Not everyone can resize the /* WCAG recommends a max line width. Not everyone can resize the
* viewport. This isn't for large blocks of text yet, so we don't have * viewport. This isn't for large blocks of text yet, so we don't have
* to go by SC 1.4.8. * to go by SC 1.4.8.
* 45em = lowest acceptable width for titles, nav, footers, etc */ * 40em = lowest acceptable width for titles, nav, footers, etc */
max-width: 42em; max-width: 40em;
/* Phone cases can cover the edges. Swipe-from-edge navigations /* Phone cases can cover the edges. Swipe-from-edge navigations
* should not conflict with the page elements. Focus outlines for * should not conflict with the page elements. Focus outlines for
@ -90,7 +90,7 @@ html {
li[itemprop="dataFeedElement"], li[itemprop="dataFeedElement"],
.narrow { .narrow {
margin: auto; margin: auto;
max-width: 35em; max-width: 34em;
} }
/* Enable containment, especially useful for achive pages with /* Enable containment, especially useful for achive pages with
@ -101,11 +101,13 @@ html {
/* We increase the target size of h2/h3 links in a way that would cause /* We increase the target size of h2/h3 links in a way that would cause
* issues with content containment */ * issues with content containment */
article > :not(h2):not(h3) { article > :not(h2):not(h3) {
contain: inline-size layout paint style; contain: inline-size layout paint;
/* Add padding on both sides so that focus outlines don't escape their /* Add padding on both sides so that focus outlines don't escape their
* containers. This will let us enable CSS containment without * containers. This will let us enable CSS containment without
* clipping overflowing elements. */ * clipping overflowing elements. */
padding: 0 .5em; padding: 0 .5em;
margin-top: .25em;
margin-bottom: .25em;
} }
/* Align titular h1 with top nav and body text. */ /* Align titular h1 with top nav and body text. */
@ -115,16 +117,24 @@ html {
/* Archive pages can get long. Allow them to get long without slowing /* Archive pages can get long. Allow them to get long without slowing
* down the browser by using content-visibility. */ * down the browser by using content-visibility. */
h2,
h3,
aside > a, aside > a,
footer, footer,
dt, dt,
a[role="doc-backlink"], a[role="doc-backlink"],
section[role="doc-endnotes"], section[role="doc-endnotes"],
li article { li article,
summary {
content-visibility: auto; content-visibility: auto;
contain-intrinsic-size: auto 3em; contain-intrinsic-size: auto 3em;
} }
dt,
h3 {
contain-intrinsic-size: 1.5em;
}
footer, footer,
li article { li article {
contain-intrinsic-size: auto 16em; contain-intrinsic-size: auto 16em;
@ -140,33 +150,37 @@ html {
contain-intrinsic-size: auto 50em; contain-intrinsic-size: auto 50em;
} }
summary {
/* It's not obvious that a <summary> has button semantics.
* "cursor: pointer" is used on MDN, web.dev, GitHub, gov.uk, and
* others so it's not "novel" and won't surprise users. */
cursor: pointer;
}
/* Full-width elements (e.g. display: block) have known widths, so /* Full-width elements (e.g. display: block) have known widths, so
* contain their widths. */ * contain their widths. */
html,
body,
main,
article, article,
h1, h1,
h2,
h3,
pre, pre,
dt, dt,
summary { summary,
contain: inline-size layout paint style; section[role="doc-endnotes"] {
contain: inline-size layout paint;
} }
p, p,
h2, figure {
h3 { contain: inline-size layout;
contain: inline-size layout style; }
article > h2 {
margin: .25em 0;
padding: .25em 0;
} }
/* If we have a list of disclosure widgets, we need some /* If we have a list of disclosure widgets, we need some
* non-interactive space on the screen that's safe to tap. */ * non-interactive space on the screen that's safe to tap. */
form, form,
li details { details {
contain: inline-size layout;
margin: .5em 0; margin: .5em 0;
} }
@ -198,7 +212,6 @@ html {
dt { dt {
padding: 1em .5em; padding: 1em .5em;
margin: -.25em 0 -.25em -.5em; margin: -.25em 0 -.25em -.5em;
contain-intrinsic-size: auto 1.5em;
} }
/* <dt> should not be closer to the previous <dd> than the following <dd>. /* <dt> should not be closer to the previous <dd> than the following <dd>.
@ -209,6 +222,7 @@ html {
dt > a, dt > a,
aside > a { aside > a {
contain: content;
margin: -.75em -.25em; margin: -.75em -.25em;
} }
@ -219,7 +233,6 @@ html {
/* List items with direct hyperlink children should only have one /* List items with direct hyperlink children should only have one
* hyperlink. */ * hyperlink. */
li > a, li > a,
h3 > a,
aside > a, aside > a,
nav ol a { nav ol a {
display: inline-block; display: inline-block;
@ -228,14 +241,29 @@ html {
/* Increase tap-target size of title links. */ /* Increase tap-target size of title links. */
h2 > a, h2 > a {
contain: content;
display: inline-block;
/* Mis-alignment, I have no clue why it's there. */
margin: 0 .125em;
padding: .25em;
}
h3 > a { h3 > a {
contain: content; contain: content;
display: inline-block; display: inline-block;
padding: .5em .25em; padding: .5em .25em;
} }
article > h3 {
padding: .25em;
margin: 0 0 0 -.5em;
}
/* align h-feeds in sections; they typically follow articles. */ /* align h-feeds in sections; they typically follow articles. */
a[role="doc-backlink"],
section article p { section article p {
margin-left: -.5em; margin-left: -.5em;
} }
@ -256,8 +284,11 @@ html {
padding-top: 0; padding-top: 0;
} }
/* stylelint-disable selector-max-compound-selectors -- simplest way to describe link-lists */
:not(nav) > ul li > a,
nav:not([itemprop="breadcrumb"]) li, nav:not([itemprop="breadcrumb"]) li,
ol li > a { ol li > a {
/* stylelint-enable selector-max-compound-selectors */
margin: .25em; margin: .25em;
} }
@ -265,12 +296,13 @@ html {
a[role="doc-backlink"] { a[role="doc-backlink"] {
contain: content; contain: content;
display: inline-block; display: inline-block;
margin-left: -.5em;
padding: .75em .5em; padding: .75em .5em;
} }
/* skip link: make it invisible until focused, and put it on the top. */ /* skip link: make it invisible until focused, and put it on the top. */
a[href="#h1"] { a[href="#h1"] {
contain: content;
content-visibility: auto;
padding: 0 .25em; padding: 0 .25em;
position: absolute; position: absolute;
top: -2em; top: -2em;
@ -292,7 +324,7 @@ sup > a {
* contrast thresholds on the dark theme. Also prevent them from messing * contrast thresholds on the dark theme. Also prevent them from messing
* with line-height. */ * with line-height. */
sup { sup {
font-size: 0.9em; font-size: 0.85em;
line-height: 0; line-height: 0;
} }
@ -361,7 +393,7 @@ h1 {
/* Very narrow screens: full hyphenation. /* Very narrow screens: full hyphenation.
* This is the typical width of a smart feature phone. */ * This is the typical width of a smart feature phone. */
@media (max-width: 15em) { @media (max-width: 250px) {
body { body {
font-size: 100%; font-size: 100%;
-webkit-hyphens: auto; -webkit-hyphens: auto;