显示 HN:magick.css – 巫师的极简 CSS
Show HN: magick.css – Minimalist CSS for Wizards

原始链接: https://css.winterveil.net

Magick.css 是一个极简、无类的 CSS 框架,旨在使编码变得更容易、更愉快。 它有一个文件,其中包含解释每个决定的注释。 风格灵感来自 LaTeX、老派桌面角色扮演游戏规则手册、concrete.css 和 Tufte CSS,注重可读性和有效传达信息,同时保持优雅和对不同设备和屏幕尺寸的适应性。 该框架无需 JavaScript 即可使用。 它包括段落、标题、表格和图形等结构组件,以及各种文本样式、交互式表单和输入,以及旁注和自动编号代码等附加功能。 为了实现它,用户可以选择直接添加文件、通过 CDN 或通过 npm 并导入它。 在使用中,magick.css 与 Normalize.css 配合使用效果最佳。 布局涉及使用容器 div 来维护响应式、可读的列布局,并使用 hr 元素在视觉上分隔内容。 排版特征包括标题 1-4、段落、链接、强调、下划线、小文本和编码文本。 结构化内容涵盖简单的内容(例如列表)和复杂的结构(例如表格)。 交互性包括复选框、单选按钮、字段集、按钮和表单。 媒体可以与图形和标题集成。 其他附加功能包括带有自动编号的旁注和可自定义的代码块行号。

本文讨论了人们对网站中特定字体和 CSS 设计的偏好,以及一些技术见解。 作者表达了对字体和风格的钦佩,但也提到由于行高而导致阅读困难。 其他人分享他们的观点,讨论各个方面,例如可访问性、与不同语言的兼容性以及对简约设计的偏好。 还提到了 Tufte CSS,这是一些用户最喜欢的。 改进演示文稿的一些建议包括更好的文档、非最小化版本的可用性、页眉和页脚的正确放置以及避免使用大写脚本字体。 总体而言,这是欣赏网页设计美学并了解清晰、易于访问的在线交流重要性的个人之间的对话。
相关文章

原文

by winterveil

In the grand compendium of universal knowledge, it is universally acknowledged that the scribbles of a wizard not only transcend the mundane but are, without a shadow of a doubt, the most exhilarating form of notation known to humanoid kind. For who could resist the allure of a well-placed spell in the margins?

Albus Greybeard, On the Virtues of Mystical Marginalia, 1132

Fundamentals

magick.css is a minimalistic, (mostly) classless CSS framework that is designed to be easy to use and easy to understand. It is contained in a single file, and every choice is commented. The goal is to achieve an elegant, but magically playful look, while maximizing readability and the ability to convey information; somewhat akin to the notes of a wizard.

The framework retains its beauty and functionality across all devices and screen sizes, and works entirely without JavaScript. It is inspired by LaTeX, old school TTRPG rulebooks, CSS frameworks like concrete.css and Tufte CSS and the "usability as design" ethic of brutalism.

How to use magick.css

The easiest way to check out magick.css for your own project is to add it from a CDN. Just add these two lines to your html :


You could also just download the magick.css file from this repo, and include it into your html as you normally would:

You could also add magick.css to your JS project like this:

npm install normalize.css magick.css

And import them in your code:

import 'normalize.css'
import 'magick.css'

For anything beyond that: magick.css should work with any HTML5 document, as it is 99% classless. There are some cool features that you can use, though; just scroll down to discover them!

Layout

To have your page structured as a responsive, readable column, wrap all of your content in

tags, and then use
tags to break up long form content content into sections. This page is a good example of how to do this.

(You could of course just ignore this advice and use magick.css for typography and styled components only.)

Here is a simple example of the usual structure:


  
  
  
    

To add tangential information, magick.css uses the

Typography

Here is a showcase of the typography that magick.css offers:


Heading 2: A subtitle beneath, where chapters await.

Heading 3: With secrets whispered, plots thicken here.

Heading 4: Fine details shared, the message stands clear.

Paragraphs flow, a river of text,

Links like portals, where will we go next?

Strong as stone, our words firmly stand,

Emphasized whispers, softly they land.

Underlined secrets, subtly hinted,

Small, yet mighty, our words are minted.

Code speaks in logic, crisp and neat,

Typography's spell, now complete.

Headings below

are not styled by magick.css; they are usually not needed for hierarchical structuring, but instead for very specific use cases. So should you need them, you can style them as you see fit.

[It is] notable that the Feynman lectures [...] write about all of physics in 1800 pages, using only 2 levels of hierarchical headings: chapters and A-level heads in the text.

Structured Content

Lists

Lists are kept simple, as to not distract from the content:

  • This is...
  • ... an unordered list.

  1. This is...
  2. ... an ordered list.

And this weird fellow here...
... is a description list.

Tables

In a similar manner to lists, tables are clear and concise, directing reader focus to the data at hand:

Potion Main Ingredient Catalyst
Glow Dew Bioluminescent algae (81mg) 🜼
Float Leaf Dandelion puff (61mg) 🝆
Might Brew Ginseng root (78mg) 🝀
Vanish Draft Mimosa pudica (26mg) 🜞
Remembrance Tea Ginkgo biloba (39mg) 🜇

Forms & Input

Interactive elements can be used on their own, or as part of a form. Keep reading to see examples of both.

Buttons

Text Inputs

Free standing text inputs are not opinionated in regards to their size or placement, as their use can vary greatly. Here are some examples: