Solved

CSS & Jquery script to fade in images and rollover fades Not working in IE

Posted on 2011-03-10
10
575 Views
Last Modified: 2012-06-27
Hi,

Having real problems trying to display this test page properly in IE 8,7,&6 and can't figure out why?
Really could use some help tracking this down as it works perfectly in all other browsers I've tested (Safari Opera Chrome Firefox)
thanks
0
Comment
Question by:sany101
  • 5
  • 4
10 Comments
 
LVL 13

Expert Comment

by:darren-w-
ID: 35094020
ie uses somthing different to Opcity:

http://www.w3schools.com/css/css_image_transparency.asp

ie: filter:alpha(opacity=x).
0
 

Author Comment

by:sany101
ID: 35094364
Well I guess I'm missing something because this example which is which is what I was using in my test works perfectly all the way back to I.E 6?
0
 
LVL 13

Expert Comment

by:darren-w-
ID: 35094633
Your right:

this works though in ie8:(have taken the heights out of the image definitions)
<html>
    <head>
        <title>test</title>
        <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>

        <style type="text/css">
            html,body {

                position:absolute;
            }
            #galleryHolder {
                width:354px;
            }
            /* Hover Fade Styling */
            div.fadeHoverGallery {
                margin:10px;
                position: relative;
                width: 334px;
                height: 176px;
            }
            img.a {
                display:block;
                position: absolute;
                left: 0;
                top: 0;
                z-index: 10;
            }
            img.b {
                display:block;
                position: absolute;
                left: 0;
                top: 0;
            }

        </style>
        <!-- scripts -->


        <!-- On Load Fade -->

        <!-- Roll Over Fade -->
        <script type='text/javascript'>
            $(function(){

                $("img.a").hover(
                function() {
                    $(this).stop().animate({"opacity": "0"}, "slow");
                },
                function() {
                    $(this).stop().animate({"opacity": "1"}, "slow");
                });

            });
        </script>
    </head>
    <body>
        <div id="galleryHolder">
            <div class="gallery"><div class="fadeHoverGallery"> <a href="#"><img src="http://sany.co.uk/images/image_a.jpg" class="a" alt=""/><img src="http://sany.co.uk/images/image_b.jpg"  class="b" alt=""/></a><!-- end fadeHoverGallery --></div>
                <div class="fadeHoverGallery"> <a href="#"><img src="http://sany.co.uk/images/image_a.jpg"  class="a" alt=""/><img src="http://sany.co.uk/images/image_b.jpg"  class="b" alt=""/></a><!-- end fadeHoverGallery --></div>
                <!-- end gallery --></div>
            <!-- end galleryHolder --></div>
    </body>
</html>

Open in new window

0
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 
LVL 13

Expert Comment

by:darren-w-
ID: 35094658
Works fine in ie6 too

Darren
0
 

Author Comment

by:sany101
ID: 35094738
Thanks Darren, however I still need the images to fade on load which you've removed:

<script type="text/javascript">
$(function(){
	$(".gallery").preloader();
	
	});

Open in new window


0
 
LVL 13

Expert Comment

by:darren-w-
ID: 35095260
I've used this preloader instead, it works with ie:

http://flesler.blogspot.com/2008/01/jquerypreload.html


<html>
    <head>
        <title>test</title>
        <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>

        <style type="text/css">
            html,body {

                position:absolute;
            }
            #galleryHolder {
                width:354px;
            }
            /* Hover Fade Styling */
            div.fadeHoverGallery {
                margin:10px;
                position: relative;
                width: 334px;
                height: 176px;
            }
            img.a {
                display:block;
                position: absolute;
                left: 0;
                top: 0;
                z-index: 10;
            }
            img.b {
                display:block;
                position: absolute;
                left: 0;
                top: 0;
            }

        </style>

        <script type="text/javascript" src="preload.js"></script>

        <script type='text/javascript'>
            $(function(){
                $.preload(".gallery");
                $("img.a").hover(
                function() {
                    $(this).stop().animate({"opacity": "0"}, "slow");
                },
                function() {
                    $(this).stop().animate({"opacity": "1"}, "slow");
                });

            });
        </script>
    </head>
    <body>
        <div id="galleryHolder">
            <div class="gallery"><div class="fadeHoverGallery"> <a href="#"><img src="http://sany.co.uk/images/image_a.jpg" class="a" alt=""/><img src="http://sany.co.uk/images/image_b.jpg"  class="b" alt=""/></a><!-- end fadeHoverGallery --></div>
                <div class="fadeHoverGallery"> <a href="#"><img src="http://sany.co.uk/images/image_a.jpg"  class="a" alt=""/><img src="http://sany.co.uk/images/image_b.jpg"  class="b" alt=""/></a><!-- end fadeHoverGallery --></div>
                <!-- end gallery --></div>
            <!-- end galleryHolder --></div>
    </body>
</html>

Open in new window

0
 

Author Comment

by:sany101
ID: 35095404
Again thanks Darren but I think you've miss understood what I was using the original pre-load script for. It was to fade the images.
 check out the original test page in firefox to see what I mean.
Thanks
0
 
LVL 13

Expert Comment

by:darren-w-
ID: 35095508
Hi,

Where have you got the preloader method from? Its obviously conflicting with the animate effect, perhaps you could look at others that don't conflict?

Busy now but will take a look later.

D
0
 
LVL 6

Accepted Solution

by:
blueghozt earned 500 total points
ID: 35111532
your preloader definitely borks IE, not sure how

but try a simpler method and maybe tweak the numbers to suit:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en"> 
<head>
<style type="text/css">



#galleryHolder {

	width:354px;

}

/* Hover Fade Styling */

div.fadeHoverGallery {

	margin:10px;

	position: relative;

	width: 334px;

	height: 176px;

	}

img.a {

	display:none; 

	position: absolute;

	left: 0;

	top: 0;

    z-index: 10;
	
	border:0;

	}

img.b {

	display:block; 

	position: absolute;

	left: 0;

	top: 0;
	
	border:0;

	}



</style>

<!-- scripts -->

<script type="text/javascript" src="js/jquery-1.4.3.min.js"></script>

<script type="text/javascript" src="js/jquery.preloader.js"></script>

<!-- On Load Fade -->


<!-- Roll Over Fade -->

<script type='text/javascript'>

$(document).ready(function(){

	$("img.b").hide();
	$("img.first").fadeIn(2000);
	$("img.second").fadeIn(4000);
	$("img.b").fadeIn(4000);


	$("img.a").hover(

	function() {

	$(this).stop().animate({"opacity": "0"}, "slow");

	},

	function() {

	$(this).stop().animate({"opacity": "1"}, "slow");

	});


});

</script>

</head>

<body>

	<div id="galleryHolder">

		<div class="gallery">

			<div class="fadeHoverGallery">
				<a href="#">
					<img src="images/image_a.jpg" width="334" height="176" class="a first" alt="" />
					<img src="images/image_b.jpg" width="334" height="176" class="b" alt="" />
				</a>	
			</div><!-- end fadeHoverGallery -->

			<div class="fadeHoverGallery">
				<a href="#">
					<img src="images/image_a.jpg" width="334" height="176" class="a second" alt="" />
					<img src="images/image_b.jpg" width="334" height="176" class="b" alt="" />
				</a>
			</div><!-- end fadeHoverGallery -->
		
		</div><!-- end gallery -->
		
	</div><!-- end galleryHolder -->

</body>

</html>

Open in new window

0
 

Author Closing Comment

by:sany101
ID: 35128793
Perfect thanks
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
In this tutorial viewers will learn how add a full-size background image to a webpage using CSS3. Create a new HTML document with an internal stylesheet.: In CSS, define the html element to have a background image. Use a high resolution image.: In t…
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

785 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question