【问题标题】:CSS Background Image Starts Blurry and then Comes into FocusCSS 背景图像开始模糊然后成为焦点
【发布时间】:2016-09-18 23:37:56
【问题描述】:

我正在使用 CSS 加载背景图像,但图像继续模糊并在几秒钟后聚焦,我该如何解决这个问题?

我在这个问题上看到了一些答案,但对我的情况没有帮助:How to prevent the background image from getting blurry

发生这种情况的原因是什么?

非常感谢任何帮助

html:

<div class="first-row-container">
  <div id="one-box" class="first-row-styles animation-target"></div>
  <div class="divider"></div>
  <div id="two-box" class="first-row-styles animation-target"></div>
  <div class="divider"></div>
  <div id="three-box" class="first-row-styles animation-target"></div>
  <div class="divider"></div>
  <div id="four-box" class="first-row-styles animation-target"></div>
<div>

css:

#one-box {
  background-image: url("your-brand-here.jpg");
  background-size: 100% 100%;
  image-rendering: -webkit-optimize-contrast;
  border-style: solid;
  border-width: 2px;
  border-color: #7f8c8d;
}

.first-row-container {
  margin-left: 13%;
}

【问题讨论】:

    标签: html css image


    【解决方案1】:

    听起来您可能正在使用progressive compressed jpg 图像。这种类型的压缩会导致图像在多次传递中被渲染,每次传递都会增加图像的细节级别。

    当您的图像非常大时,就分辨率和/或文件大小而言,这可能会导致图像保真度显着提高,这与您所描述的事件相对应。你能告诉我your-brand-here.jpg的分辨率和文件大小是多少吗?

    如果是这种情况,您可以通过降低分辨率(我通常将图像转换为它们将显示的确切分辨率)和降低 jpeg 压缩质量来减少图像的加载时间。

    希望这会有所帮助!

    【讨论】:

    • 嗨,杰夫,感谢您的回答。我当前的文件大小是 315*218,文件大小是 45kb,dpi 是 72px/in。对你所做的修改有什么建议吗?
    • 您提到的这些图像属性实际上应该不是问题。我假设您使用的是更大的图像。不过,您可以尝试保存新版本,并确保将其保存为“基线”而不是“渐进式”或“交错式”。在 Photoshop 中,您可以通过取消选中“保存为网络”对话框中的“渐进式”来实现此目的。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-06-08
    • 2020-07-13
    • 2023-01-13
    • 1970-01-01
    • 1970-01-01
    • 2013-10-22
    • 1970-01-01
    相关资源
    最近更新 更多