Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个 100 像素宽 / 100 像素高的 PNG 图像。
我用 CSS 调整它的大小:img { max-width: 70px }。
img { max-width: 70px }
结果很模糊。
可能出了什么问题?
这可能是因为 100px 的正方形没有精确地划分为 70px,浏览器在尝试动态调整图像的大小和插入图像的像素时错误地渲染了图像的位。试试max-width: 50pxormax-width: 75px看看它是否仍然模糊。
max-width: 50px
max-width: 75px
如果您可以除以 2/4/8 的倍数以精确到您想要的大小,则调整图像大小会容易得多。
(假设您不在 HiDPI/视网膜屏幕上,在这种情况下,这是因为您在 75px 正方形上没有足够的像素来渲染完整的视网膜质量图像。)