Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

使用img当背景,下面有一个几px的白条 #39

Open
lovelmh13 opened this issue Jun 22, 2020 · 0 comments
Open

使用img当背景,下面有一个几px的白条 #39

lovelmh13 opened this issue Jun 22, 2020 · 0 comments

Comments

@lovelmh13
Copy link
Owner

原因

由于img是行内标签造成的

默认对其方式为vertical-align: baseline(基线对齐) 。图片默认的垂直对齐方式是基线,基线的位置与字体相关,所以在某些时候,图片底部的空隙可能是 2px,而有时可能是 4px 或更多。不同的 font-size 会造成这个空隙的高度大小。

办法

  1. 改成块级元素
  2. 加上vertical-align middle属性

参考

img标签底部总是留有一条白色空隙

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant