简体   繁体   English

通过CSS3或JS或jquery帮助实现过渡效果

[英]helping in transition effect by CSS3 or JS or jquery

I want to change the background-image of this picture while moving to another one on my images folder like this example that's my code 我想改变这张照片的背景图像,同时移动到我的图像文件夹上的另一个图片,就像这个例子那样是我的代码

CSS CSS

.image {

    position: relative;
        overflow: hidden;
    -webkit-transition: all 0.5s ease-out;
    -moz-transition: all 0.5s ease-out;
    transition: all 0.5s ease-out;
        opacity:1;
filter:alpha(opacity=100);

}
.image:hover {

        opacity:0;
filter:alpha(opacity=0);
    -moz-transform:  scale(1.00) rotate(0deg) translate(0px, 100px) skew(0deg, 0deg);
    -webkit-transform:   scale(1.00) rotate(0deg) translate(0px, 100px) skew(0deg, 0deg);
    transform: scale(1.00) rotate(0deg) translate(0px, 100px) skew(0deg, 0deg); transform-origin: 0% 0%
    background-color:#36F;

    }

HTML HTML

<div id="image_holder_1" class="image_holder">
    <img id="image_1" class="image" src="images/esu.gif" />
</div>

jQuery.cycle is your answer. jQuery.cycle是你的答案。

<script type="text/javascript">

    $(document).ready(function() {
        $('.image_holder').cycle({
                fx: 'fade' // choose your transition type, ex: fade, scrollUp, shuffle, etc...
        });
    });
</script>

You should remove the "image" id and image elements should be contained inside your "image_holder" that contain links to the images you want to cycle (transition) through. 您应该删除“图像”ID,图像元素应包含在“image_holder”中,其中包含指向要循环(转换)的图像的链接。 Your html will then look something like this: 您的HTML将看起来像这样:

<div id="image_holder_1" class="image_holder">
         <img src="images/esu.gif"/>
         <!-- Your other image source(s) goes here -->
</div>

If your image transition worked the way that you liked with your css, use the css for the transition and omit the transition type in the jQuery. 如果您的图像转换按照您喜欢的css方式工作,请使用css进行转换,并在jQuery中省略转换类型。 Here is a link to the different transitions that may be useful to you by using jQuery.cycle. 以下是使用jQuery.cycle可能对您有用的不同转换的链接。 jQuery.cycle transitions jQuery.cycle转换

您的示例中的效果在CSS中无法实现,无法取消过渡动画,因此每个动画都必须完成CSS中的鼠标悬停和鼠标移出事件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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