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

推荐订阅源

V
Visual Studio Blog
Y
Y Combinator Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Apple Machine Learning Research
Apple Machine Learning Research
爱范儿
爱范儿
IT之家
IT之家
量子位
小众软件
小众软件
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
有赞技术团队
有赞技术团队
罗磊的独立博客
S
SegmentFault 最新的问题
博客园_首页
N
Netflix TechBlog - Medium
月光博客
月光博客
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
aimingoo的专栏
aimingoo的专栏
T
Tailwind CSS Blog
M
MIT News - Artificial intelligence
A
About on SuperTechFans
The Cloudflare Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
腾讯CDC
MyScale Blog
MyScale Blog

Taxodium

用 Tamper-monkey 集成 Kagi Translate (2) Zine#58 辣椒炒肉 用 Tamper-monkey 集成 Kagi Translate TIL:Punycode Zine#57 香港雞公嶺 給博客添加純文本版本 在 Emacs 中用漢典查詢倉頡碼 Album#48 Album#47 Re: Bloggers, can we make better titles for our posts? Album#46 Zine#56 Blaugust 2026 Feeds Album#45 Album#44 Zine#55 Album#43 請開啟 JavaScript 以繼續搜尋 近期觀影 小象超市鮮啤簡評 Zine#54 TIL: lang 属性會影响文字的尺寸 Zine#53 Elfeed 4.0.0 使用分享 分享一些 Zen 瀏覧器好用的功能 Zine#52 Zine#51 Album#42
TIL: 移除图片下方多余的空白
Spike Leung · 2026-05-19 · via Taxodium

在当前场景下我并不想要這点多余的空白,可以通過以下方法解决:

1.將图片設為 display: block; ,变成块级元素,不再是行內元素,也就不受基线影响

<div style="border: 2px solid;">
  <img style="display:block;" src="/images/album/20251226T172918--梦想家-the-dreamer__20241018_khalilfong_albumwall_image_方大同.webp" />
</div>


2.給图片容器設置 line-height: 0; ,行高為 0,基线底部也不存在高度

<div style="border: 2px solid; line-height: 0;">
  <img src="/images/album/20251226T172918--梦想家-the-dreamer__20241018_khalilfong_albumwall_image_方大同.webp" />
</div>


3.給图片設置 vertical-align: top; /​* or bottom *​/ ,不和基线对齐,和行的上下边䧘对齐

<div style="border: 2px solid;">
  <img style="vertical-align: top;" src="/images/album/20251226T172918--梦想家-the-dreamer__20241018_khalilfong_albumwall_image_方大同.webp" />
</div>

你可以基于使用场景选择合适的方案,我一般会用 vertical-align: top; ,应该是其中副作用最小的。