Solved

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

Posted on 2011-03-10
10
550 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
 
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
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

CSS is a visual language used to classify objects and define rules about how they should be displayed. CSS skills aren’t restricted to developers anymore, there is a big benefit to having a basic understanding of the language, regardless of your occ…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
In this tutorial viewers will learn how add a scalable full-width header using CSS3. Create a new HTML document with an internal stylesheet. Set a tiled background.:  Create a new div and name it Header. Position it with position:absolute at the top…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

706 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now