Note that there are some explanatory texts on larger screens.

plurals
  1. POFading Image Background with Stretched BG in IE8 (Javascript and CSS)
    primarykey
    data
    text
    <p>I need to create a fading background image that stretches to fill the browser. The following code works perfectly in every single browser except in IE8 and below. The IE8 issue is that I can get it to fade but not stretch or to stretch but not fade - Not both at the same time.</p> <p>THE JAVASCRIPT</p> <pre><code>$(document).ready(function(){ var imgArr = new Array( // relative paths of images 'images/bg01.jpg', 'images/bg02.jpg', 'images/bg03.jpg', 'images/bg04.jpg', 'images/bg05.jpg' ); var preloadArr = new Array(); var i; /* preload images */ for(i=0; i &lt; imgArr.length; i++){ preloadArr[i] = new Image(); preloadArr[i].src = imgArr[i]; } var currImg = 0; changeImg(); var intID = setInterval(changeImg, 7500); /* image rotator */ function changeImg(){ $('#bgFade').animate({opacity: 0}, 1000, function(){ $(this).css({ 'background':'url(' + preloadArr[currImg++%preloadArr.length].src +') center 49px', '-webkit-background-size':'cover', '-moz-background-size':'cover', '-o-background-size':'cover', 'background-size':'cover', 'filter':'progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\''+ preloadArr[currImg++%preloadArr.length].src +'\', sizingMethod=\'scale\'' }); }).animate({opacity: 1}, 1000); } }); </code></pre> <p>Here is the line I added to make it stretch in IE8 (and below) but it breaks the fading functionality. It would be great if IE8 supported "background-size" but it does not.</p> <pre><code>'filter':'progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\''+ preloadArr[currImg++%preloadArr.length].src +'\', sizingMethod=\'scale\'' </code></pre> <p>THE CSS/HTML</p> <pre><code>#bgFade { position:fixed; top:0; left:0; height:100%; width:100%; z-index:-1; } &lt;div id="bgFade"&gt;&lt;/div&gt; </code></pre> <p>I hope there is a solution to both stretch and fade the background images in IE8. If the solution only works in IE8 but not in IE7 or below that is fine. IE8 and above is my only concern at the moment. Thanks in advance!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload