[CSS] Draw Simple Icons with CSS
Using pseudo-elements like ::before
and ::after
we can draw some simple icons without having using image assets which can help reduce the number of requests and improve performance.
const Radio = ({ active, children, onChange }) => { return ( <label className="filter"> <input checked={active} type="radio" name="filter" className="filter__radio" onChange={e => { onChange(); }} /> <span className={`filter__label--${children.toLowerCase()}`}>{children}</span> </label> ); };
[class^="filter__label"] { position: relative; display: inline-block; padding-left: 16px; color: rgba(236,240,241,0.3); } [class^="filter__label"]:hover { color: #ccc; } .filter__radio:checked + [class^="filter__label"] { color: #fff; } [class^="filter__label"]::before, .filter__label--all::after { content: ''; position: absolute; top: 5px; left: 0; background: #647380; display: block; width: 10px; height: 10px; border-radius: 5px; box-shadow: 0 0 2px 1px rgba(0,0,0,0.2); } .filter__radio { position: absolute; opacity: 0; } .filter__label--all { padding-left: 21px; } .filter__label--all::after { left: 5px; } .filter__radio:checked + .filter__label--all::before { background: #af544f; } .filter__radio:checked + .filter__label--all::after { background: #16a085; } .filter__radio:checked + .filter__label--active::before { background: #af544f; } .filter__radio:checked + .filter__label--completed::before { background: #16a085; } @media only screen and (min-width: 730px) { .container { max-width: 720px; justify-content: flex-end; } .todo-app { border-radius: 4px 4px 0 0; } .todo-list { order: -1; flex-direction: column; } [class^="todo-list__item"] { box-shadow: 0 1px 0 0 #e6e6e6, 0 2px 0 0 white; } .filters { border-radius: 3px 3px 0 0; order: 0; } }
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· AI技术革命,工作效率10个最佳AI工具