English 中文(简体)
jquery 图像滚动行为
原标题:jquery image rollover behaviour

允许缩略图 rc attr 在主图像窗口中替换图像 。

        $(document).ready(function(){   
            var originalimg = $( #imageMain img ).attr( src );
                $(".subImage").hover(function(){
                        var currentimg = $(this).attr( src );
                    $( .mainImage ).fadeOut(function () {
                    $( .mainImage ).attr( src , currentimg).fadeIn();
                        });
                    },function(){
                            $( .mainImage ).fadeOut(function() {
                                $( .mainImage ).attr( src , originalimg).fadeIn();
                            })
                            });
            });

Currently the behaviour does the following: 1. hover over - main image fades to white, then fades into the sub image. 2. mouse out - main image fades to white, then is replaced with the original.

我真正需要的东西 而不是在两个图像状态之间的白色转变 我希望它们能有某种重叠( 所以一个会随着另一个消失而消失)

有可能吗?

感谢 谢谢

问题回答

您不能以淡出/ 淡出/ 淡出/ 淡出方式依次对图像进行滚动。 您必须以一种替代方式实现过渡 。 我为你写了整个代码 :

    <head>
    <title>jQuery Image Rotator</title>
   <script type="text/javascript" src="jquery-1.3.2.js"></script>
    <script type="text/javascript">
      $("#photoshow").hover(function() {
        setInterval("rotateImages()", 2000); // set the interval time as your wish
    });

    function rotateImages() {
        var oCurPhoto = $( #photoShow div.current );
        var oNxtPhoto = oCurPhoto.next();
        if (oNxtPhoto.length == 0)
            oNxtPhoto = $( #photoShow div:first );

        oCurPhoto.removeClass( current ).addClass( previous );
        oNxtPhoto.css({ opacity: 0.0 }).addClass( current ).animate({ opacity: 1.0 }, 1000,
            function() {
                oCurPhoto.removeClass( previous );
            });
    }
</script>
       <style type="text/css">
         #photoShow {
        height:400px;
         width:400px;
         }
      #photoShow div {
        position:absolute;
        z-index: 0;
         }
      #photoShow div.previous {
        z-index: 1;
         }
         #photoShow div.current {
          z-index: 2;
           }
</style>
    </head>
  <body>
    <div id="photoShow">
       <div class="current">
        <img src="images/Grass.jpg" alt="Photo Gallery" width="400" height="400" class="gallery" />
    </div>
    <div>
        <img src="images/Leaf.jpg" alt="Photo Gallery" width="400" height="400" class="gallery" />
    </div>
    <div>
        <img src="images/Spring.jpg" alt="Photo Gallery" width="400" height="400" class="gallery" />
    </div>
    <div>
        <img src="images/Water.jpg" alt="Photo Gallery" width="400" height="400" class="gallery" />
    </div>
     </div>
   </body>
    </html>

将图像逐个转换。 替换为合适的类、 id 名称和图像 URL 。 希望它有所帮助!





相关问题
Using QCView and iSight to capture image

I have a QCView that loads a Quartz file which gives you iSights feedback (basically like a QTCaptureView) Everything displays fine The button simply takes a snapshot using the following simple ...

Taking picture with QTCaptureView

Is it possible to simply take a picture and save it somewhere using a QTCaptureView and Apple s built-in iSight? I ve seen lots of tutorials on recording video but none on simply taking a picture. Any ...

Transform rectangular image into trapezoid

In .NET how can I transform an image into a trapezoid. The Matrix class supports rotation, shear, etc, but I can t see a trapezoidal transformation. I m using the usual System.Drawing.* API, but I m ...

Rotate image through Y-axis on web page

What are my options for rotating an image on a web page through the Y-axis? I m not sure if I even have the terminology right. Is this called a rotate or a transform. Most of the searches that I ve ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

Editing a xaml icons or images

Is it possible to edit a xaml icons or images in the expression design or using other tools? Is it possible to import a xaml images (that e.g you have exported) in the expression designer for editing?...

Convert from 32-BPP to 8-BPP Indexed (C#)

I need to take a full color JPG Image and remap it s colors to a Indexed palette. The palette will consist of specific colors populated from a database. I need to map each color of the image to it s "...

热门标签