img ,宽度设置100%,图片会变模糊。 设置为固定宽度就很清晰

时间:2025-03-17 12:18:41

img ,宽度设置100%,图片会变模糊。 设置为固定宽度就很清晰。
比如一张图片宽度1920px:
<img src="" width="100%">
代码这样写图片会压缩的比较模糊。
<img src="" width="1920px">
这样固定宽度就不模糊了。。。

解决办法:

img {
    image-rendering: -moz-crisp-edges; /* Firefox */
    image-rendering: -o-crisp-edges; /* Opera */
    image-rendering: -webkit-optimize-contrast; /* Webkit (non-standard naming) */
    image-rendering: crisp-edges;
    -ms-interpolation-mode: nearest-neighbor; /* IE (non-standard property) */
}