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

推荐订阅源

Google DeepMind News
Google DeepMind News
Microsoft Azure Blog
Microsoft Azure Blog
博客园 - 聂微东
大猫的无限游戏
大猫的无限游戏
IT之家
IT之家
月光博客
月光博客
博客园_首页
Jina AI
Jina AI
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
AWS News Blog
AWS News Blog
S
Securelist
T
Tailwind CSS Blog
C
Cyber Attacks, Cyber Crime and Cyber Security
罗磊的独立博客
D
Docker
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Apple Machine Learning Research
Apple Machine Learning Research
Scott Helme
Scott Helme
H
Help Net Security
Project Zero
Project Zero
P
Proofpoint News Feed
D
DataBreaches.Net
Recorded Future
Recorded Future
Simon Willison's Weblog
Simon Willison's Weblog
V2EX - 技术
V2EX - 技术
The Cloudflare Blog
Hugging Face - Blog
Hugging Face - Blog
I
Intezer
Engineering at Meta
Engineering at Meta
The Register - Security
The Register - Security
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
I
InfoQ
酷 壳 – CoolShell
酷 壳 – CoolShell
雷峰网
雷峰网
S
Secure Thoughts
GbyAI
GbyAI
U
Unit 42
Blog — PlanetScale
Blog — PlanetScale
T
Threat Research - Cisco Blogs
The Last Watchdog
The Last Watchdog
Y
Y Combinator Blog
F
Fortinet All Blogs
博客园 - Franky
T
The Blog of Author Tim Ferriss
Hacker News: Ask HN
Hacker News: Ask HN
Microsoft Security Blog
Microsoft Security Blog
Stack Overflow Blog
Stack Overflow Blog
S
Security @ Cisco Blogs
Cyberwarzone
Cyberwarzone

鬼影的基地

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

前言

暴力的 div、table 堆叠不在此进行赘述,image-rendering、svg 与 canvas 不在范围内。

Box-shadow

代码写起来较为简短,也有很多的生成器。但一般需要再套个元素在外以帮助占位,浏览器缩放会影响显示效果(存在缝隙或堆叠),且不太方便自适应。

CSS Pixel Art Generator PIXEL ART TO CSS

展示柜

Linear-gradient

只需一个元素,十分方便的自适应,只需宽与高任意指定一个,甚至可以在里面写点字。但不支持透明,且代码又长又没什么生成器,写起来会不太方便。此外还应当设置 print-color-adjust: exact

简易生成代码

Mushroom linear-gradient
/** 代码修改自https://codepen.io/cgreinhold/pen/rNagxoK **/
const pixels = [
	["","#F00"],
	["#0F0","#00F"]
];

const pixelArt = document.getElementById("pixelart");
const width = pixels[0].length;
const height = pixels.length;

const backgroundImage = [];
const backgroundSize = [];
for (let i = 0; i < pixels.length; i++) {
	const pixel = pixels[i];
	const percent = 100 / pixel.length;
	let cont = 0;
	const backgroundParts = [];
	for (let j = 0; j < pixel.length; j++) {
		const pixelColor = pixel[j] || "#FFF";
		let backgroundImagePart = "";
		backgroundImagePart += `${pixelColor} ${cont}%`;
		cont += percent;
		backgroundImagePart += `, ${pixelColor} ${cont}%`;
		backgroundParts.push(backgroundImagePart);
	}
	backgroundImage.push(
		`linear-gradient(to right, ${backgroundParts.join(", ")})`
	);
	backgroundSize.push(`100% ${((i + 1) * 100) / height}%`);
}
pixelArt.style.aspectRatio = width / height;
pixelArt.style.backgroundImage = backgroundImage.join(",");
pixelArt.style.backgroundRepeat = "repeat-x";
pixelArt.style.backgroundSize = backgroundSize.join(",");
pixelArt.removeAttribute("id")

展示柜