Quick question on progressive JPG backgrounds, if anyone knows.
It appears that Firefox ignores the "progressiveness" of JPEGs if they are set as CSS backgrounds and waits until the image is fully loaded until displaying. I have Chrome and IE loading the background images progressively but Firefox just pops them in at full quality.
I'm seeing the proof in front of me , but finding little to no info on it online. Just unanswered forum questions here and there.
Anyone know anything about this? Is it a bug Mozilla know about or what is going on?
Edit: Test case provided by easwee http://sample.easwee.net/jpgProgressive/index.html
Make sure the image path is set correctly in the background-image url. Once you have made sure that your CSS file is linked correctly, also check that the image itself is set correctly. Again, you will want to open your code inspector in the browser to check.
Using CSS, you can set the background-size property for the image to fit the screen (viewport). The background-size property has a value of cover . It instructs browsers to automatically scale the width and height of a responsive background image to be the same or bigger than the viewport.
Try this , background: url(../IMAGES/background. jpg) no-repeat center center fixed; -webkit-background-size: cover; -moz-background-size: cover; -o-background-size: cover; background-size: cover; For more information , follow this Perfect Full Page Background Image !!
To set the background image of a webpage, use the CSS style. Under the CSS <style> tag, add the property background-image. The property sets a graphic such as jpg, png, svg, gif, etc. HTML5 do not support the <body> background attribute, so CSS is used to change set background image.
I went digging in since I am working on a similar problem at the moment.
Results from personal tests on this test case + Fiddler 2 to simulate slow modem speed:
as HTML <img> as CSS background
Firefox (ver 25.0.1) works no support
Chrome (ver 32.0.1700.107 m) works works
Safari (windows 5.1.7) no support no support
Seems to me from the tests (and from an extensive web search) that the only browser that currently supports progressive background images in CSS is Chrome.
Workaround: A nice workaround I've been using in cases where the image had to be visible before it finished loading the full size, is to load an extremely compressed image under the high resolution image. So you have the compressed graphic under the element until the full resolution graphic loads over it.
<div style="background:url(extremely_compressed.jpg);">
<div style="background:url(high_quality.jpg);">
</div>
</div>
Workaround 2:
Since Firefox does support progressive loading on <img>
tag, you could try setting the <img>
to position:absolute
(or fixed
) and have it load behind the content with a lower z-index
.
Wordaround 3 - CSS3: Use multiple background images if you don't need to support old browsers.
background-image: url('extremely_compressed.jpg'),url('high_quality.jpg');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With