Would you reconsider your Tufte CSS sidenotes?
本文为原文前 6,000 字符的节选翻译,完整内容请查看原文。
TL;DR: Using “clever CSS tricks” for Tufte CSS, or sidenotes, is probably a bad idea, as inlining sidenotes as the official Tufte CSS does can cause trouble for browser reader modes or mobile devices. This is an expansion of my rant in a comment on Lobsters about Tufte CSS. I think it might be helpful to have something you can link to, with screenshots/demonstrations of how things might fail. So here we go. However, before we start, please note that this page is not designed for viewing on narrow screens like phones. So if you are reading on a mobile device, I would recommend scrolling through the post for a feeling of sidenotes, and then turning on Reading Mode (if your browser has one).
简而言之:使用“巧妙的 CSS 技巧”来实现 Tufte CSS 或旁注(sidenotes)可能并不是一个好主意,因为像官方 Tufte CSS 那样将旁注内联处理,可能会给浏览器的阅读模式或移动设备带来麻烦。这是我对 Lobsters 上关于 Tufte CSS 的评论所做的扩展。我认为提供一个可以引用的页面,并附上故障截图或演示可能会有所帮助。所以,我们开始吧。不过在开始之前,请注意本页面并非为手机等窄屏设备设计。因此,如果您正在使用移动设备阅读,我建议您先滚动浏览文章以感受一下旁注的效果,然后开启阅读模式(如果您的浏览器支持的话)。
-
Tufte CSS Sidenotes/Margin Notes. Sidenotes are nice, and Tufte CSS beautifully demonstrates a way to incorporate sidenotes into the Web to be compatible with both wider views and narrower screens, with a little bit of CSS magic. Tufte CSS builds its sidenotes and margin notes upon inlined HTML elements plus a rather well-known CSS checkbox trick.
-
Tufte CSS 旁注/页边注。旁注很美观,Tufte CSS 精彩地展示了一种将旁注融入网页的方法,通过一点 CSS 魔法,使其既能兼容宽屏视图,也能适应窄屏设备。Tufte CSS 基于内联 HTML 元素以及一个相当著名的 CSS 复选框技巧来构建其旁注和页边注。
-
Inline Sidenotes Break Semantics. The main problem is that HTML does not really expect a less important, collapsible, floating, potentially display: block element to reside in a paragraph. And text selection, reader modes, screen readers, etc. all build on the same premise.
-
内联旁注破坏了语义。主要问题在于,HTML 并不期望一个不那么重要、可折叠、浮动且可能具有 display: block 属性的元素驻留在段落中。而文本选择、阅读模式、屏幕阅读器等功能都是基于这一前提构建的。
2.1. Non-intuitive text selection. Text selection can be non-intuitive with inline sidenotes. The above showcases what text you will actually select if you drag your mouse from “serif fonts” to “Tufte CSS”. I’m not sure what most people would expect when they try to select (and maybe copy) from “serif fonts” to “Tufte CSS”, but I certainly don’t want the sidenote to be included.
2.1. 不直观的文本选择。使用内联旁注时,文本选择可能会变得不直观。上述内容展示了如果您将鼠标从“serif fonts”拖动到“Tufte CSS”时实际选中的文本。我不确定大多数人在尝试从“serif fonts”选择(并可能复制)到“Tufte CSS”时会期望什么,但我肯定不希望旁注内容被包含在内。
2.2. Puzzling text flow. Reader modes and screen readers follow more or less the same DOM-based logic. They ignore those fancy CSS stylings and lay out text as it appears in the DOM, just like our previous text selection example. This means what looks like a pretty sidenote might turn out to be disastrous.
2.2. 令人困惑的文本流。阅读模式和屏幕阅读器或多或少遵循相同的基于 DOM 的逻辑。它们会忽略那些花哨的 CSS 样式,并按照文本在 DOM 中出现的顺序进行排版,就像我们之前的文本选择示例一样。这意味着看起来美观的旁注可能会导致灾难性的结果。