简体   繁体   中英

Image rollover effect on fancybox

I'm having some trouble overlaying a .png on my existing .jpg fancybox thumbnail image. The rest works perfect.

I have 9 images and coded a loop to create my fancybox gallery in PHP. I'm having some dificulty applying the .png over the existing .jpg thumbnail.

This is my PHP code:

<?php
        $i=1;
        $title=array("", "t1", "t2", "t3", "t4", "t5", "t6", "t7", "t8", "t9");

        for($i; $i<10; $i++)
        {

        echo "<div id='galeria' class='one-third column alpha'>
            <a title='".$title[$i]."' class='fancybox' rel='group' href='../img/galeria/big".$i.".jpg'><img src='../img/galeria/thumb".$i.".jpg' alt='' /></a>
        </div><!--end 1\3 -->";

            $i++;
            echo "<div id='galeria' class='one-third column'>
            <a title='".$title[$i]."' class='fancybox' rel='group' href='../img/galeria/big".$i.".jpg'><img src='../img/galeria/thumb".$i.".jpg' alt='' /></a>
        </div><!--end 1\3 -->";
            $i++;
            echo "<div id='galeria' class='one-third column omega'>
            <a title='".$title[$i]."' class='fancybox' rel='group' href='../img/galeria/big".$i.".jpg'><img src='../img/galeria/thumb".$i.".jpg' alt='' /></a>
            </div><!--end 1\3 -->";
        }
    ?>

I've tried using onMouseOver and onMouseOut with no success. (I'm new to JS and jQuery if you can provide detailed help I would really apreciate it).

I don't know if I understand your question, but try this:

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script>    
    $(function(){
        $(".fancybox").hover(
            function(){
                $(".imagem-hover",this).fadeIn(100);
            },
            function(){
                $(".imagem-hover",this).fadeOut(100);
            }
        );
    });
</script>
<style>
    * {position:relative;}
    .fancybox .imagem-hover {position:absolute; z-index:1; display:none;}
</style>
<div id="galeria">
    <a class="fancybox" href="imagemGrande.jpg">
        <img class="imagem-hover" src="over.png" />
        <img src="thumb.jpg" />
    </a>
    <a class="fancybox" href="imagemGrande.jpg">
        <img class="imagem-hover" src="over.png" />
        <img src="thumb.jpg" />
    </a>
    <a class="fancybox" href="imagemGrande.jpg">
        <img class="imagem-hover" src="over.png" />
        <img src="thumb.jpg" />
    </a>
</div>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM