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

推荐订阅源

F
Full Disclosure
Recorded Future
Recorded Future
T
Tenable Blog
S
Securelist
C
CERT Recently Published Vulnerability Notes
T
Threatpost
S
Schneier on Security
A
Arctic Wolf
The Hacker News
The Hacker News
C
CXSECURITY Database RSS Feed - CXSecurity.com
Know Your Adversary
Know Your Adversary
P
Privacy International News Feed
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
The Register - Security
The Register - Security
Cisco Talos Blog
Cisco Talos Blog
AWS News Blog
AWS News Blog
K
Kaspersky official blog
T
True Tiger Recordings
T
Threat Research - Cisco Blogs
V
Vulnerabilities – Threatpost
P
Palo Alto Networks Blog
T
The Exploit Database - CXSecurity.com
小众软件
小众软件
B
Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Microsoft Azure Blog
Microsoft Azure Blog
Cyberwarzone
Cyberwarzone
C
Cybersecurity and Infrastructure Security Agency CISA
T
Tor Project blog
Spread Privacy
Spread Privacy
Malwarebytes
Malwarebytes
P
Proofpoint News Feed
F
Fox-IT International blog
F
Fortinet All Blogs
P
Privacy & Cybersecurity Law Blog
G
GRAHAM CLULEY
量子位
Latest news
Latest news
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
博客园 - 叶小钗
Project Zero
Project Zero
T
Tailwind CSS Blog
N
Netflix TechBlog - Medium
Martin Fowler
Martin Fowler
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
I
Intezer
博客园_首页
腾讯CDC
H
Hackread – Cybersecurity News, Data Breaches, AI and More
D
Darknet – Hacking Tools, Hacker News & Cyber Security

鬼影的基地

CSS 自适应简单 Table CSS 像素画的方法 Safari animation Bug 在 macOS 上部署 Viper 萌娘百科水平越权漏洞 萌娘百科头像魔术字 IP 泄露 修复 iPhone 13 iOS 16 Safari 中的 Bug 命名空间 在 CSS 中进行数据类型转换 萌娘百科评论区 IP 泄露 在 iOS 的 Apple Mail 中添加 QQ邮箱 CodeMirror url() Bug CVE-2025-61638:Sanitizer::validateAttributes data-XSS CVE-2025-61638:Sanitizer::validateAttributes data-XSS 萌娘百科水平越权漏洞 萌娘百科头像魔术字 IP 泄露 修复 iPhone 13 iOS 16 Safari 中的 Bug 命名空间 在 CSS 中进行数据类型转换 萌娘百科评论区 IP 泄露 在 iOS 的 Apple Mail 中添加 QQ邮箱 CodeMirror url() Bug Safari animation Bug 在 macOS 上部署 Viper CSS 像素画的方法
CSS 自适应简单 Table
2026-05-21 · 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 等相关文档,如果还是看不懂,或许你不该在这里。