惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

酷 壳 – CoolShell
酷 壳 – CoolShell
H
Hacker News: Front Page
P
Palo Alto Networks Blog
T
ThreatConnect
Apple Machine Learning Research
Apple Machine Learning Research
博客园_首页
T
True Tiger Recordings
P
Privacy & Cybersecurity Law Blog
B
Blog
IT之家
IT之家
Last Week in AI
Last Week in AI
F
Full Disclosure
Hacker News: Ask HN
Hacker News: Ask HN
C
Comments on: Blog
Microsoft Azure Blog
Microsoft Azure Blog
C
Cybersecurity and Infrastructure Security Agency CISA
Microsoft Security Blog
Microsoft Security Blog
博客园 - 【当耐特】
N
News and Events Feed by Topic
NISL@THU
NISL@THU
腾讯CDC
雷峰网
雷峰网
Security Latest
Security Latest
李成银的技术随笔
M
Microsoft Research Blog - Microsoft Research
L
LangChain Blog
L
Lohrmann on Cybersecurity
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
C
Check Point Blog
Y
Y Combinator Blog
Recent Announcements
Recent Announcements
博客园 - Franky
N
News | PayPal Newsroom
V
V2EX
A
About on SuperTechFans
The Register - Security
The Register - Security
月光博客
月光博客
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Google Online Security Blog
Google Online Security Blog
MyScale Blog
MyScale Blog
Cisco Talos Blog
Cisco Talos Blog
Vercel News
Vercel News
WordPress大学
WordPress大学
C
Cyber Attacks, Cyber Crime and Cyber Security
The Hacker News
The Hacker News
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
爱范儿
爱范儿
A
Arctic Wolf
L
LINUX DO - 最新话题
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More

鬼影的基地

CSS 像素画的方法 Safari animation Bug 在 macOS 上部署 Viper 萌娘百科水平越权漏洞 萌娘百科头像魔术字 IP 泄露 修复 iPhone 13 iOS 16 Safari 中的 Bug 命名空间 在 CSS 中进行数据类型转换 萌娘百科评论区 IP 泄露 在 iOS 的 Apple Mail 中添加 QQ邮箱 CodeMirror url() Bug 萌娘百科水平越权漏洞 萌娘百科头像魔术字 IP 泄露 修复 iPhone 13 iOS 16 Safari 中的 Bug 命名空间 在 CSS 中进行数据类型转换 萌娘百科评论区 IP 泄露 在 iOS 的 Apple Mail 中添加 QQ邮箱 CodeMirror url() Bug Safari animation Bug 在 macOS 上部署 Viper CSS 自适应简单 Table CSS 像素画的方法
CSS 自适应简单 Table
2026-04-11 · via 鬼影的基地

前言

众所周知,Table 由于其不方便换行的固有特性,且常常存在一行大量文本,正在逐渐与现代的自适应布局脱节。Grid 与 Flex 的效果固然不错,但有没有什么方法能将简单的 Table 进行简单的自适应并保持代码(例如 Wikitext)的基本格式以对代码力较差的大众也能看懂?

答案自然是有的,当你去网上搜索便能发现一些使用 attr() 的 CSS 转换,亦或者是用 JS 进行更复杂的转换。

而本篇介绍的便是 attr() 的进阶方法,毕竟每个元素都要设置 data- 值也太烦了……

实例

@media (max-width: 576px) {
	.flextable,
	.flextable > tbody,
	.flextable tr {
		display: block;
	}
	.flextable th {
		display: none;
	}
	.flextable tr {
		margin-block: .5em;
	}
	.flextable td {
		display: list-item;
		text-align: right;
		margin-left: 4em;
	}
	@counter-style flextable-114514 {
		system: fixed;
		suffix: ":";
		symbols: "标题1" "标题2" "标题3";
	}
	.flextable#flextable-114514 {
		list-style: flextable-114514;
	}
	.flextable td::marker {
		font-weight: bolder;
	}
	.flextable td[data-th]::marker {
		content: attr(data-th) ":";
	}
}
标题1 标题2 标题3
内容1 内容2 内容3
内容4 内容5 内容6
内容7 内容8 内容9

简介

此方法仅适用于十分基础的表格,但我想这大概也挺有用的。可惜其中主要的参数 MediaWiki 的纯 CSS / 已过滤的 CSS 并不支持。

思路是将表格转换为有序列表,通过 symbols 统一指定标题。data-th 值可用于特别指定一个标题,虽然感觉没什么用。

这里不对代码进行详细解释,请自行查阅例如 MDN 等相关文档,如果还是看不懂,或许你不该在这里。