我如何逐渐放大,而改变鼠标悬停的颜色和逐渐缩小和褪色的颜色上的鼠标房子

How do I Gradual Zoom In while changing color on Mouse Hover and Gradual Zoom Out and fading color on mouse house

本文关键字:颜色 鼠标 缩小 房子 褪色 悬停 何逐渐 放大 改变      更新时间:2023-09-26

我想要实现的是逐渐缩放图像,同时让它的颜色随新图像变化。例如,图像苹果与黑色,我有另一个图像苹果与红色。当鼠标悬停在黑苹果上时,它的颜色会逐渐变红。问题是,当我将鼠标悬停时,它会立即切换到另一个图像,然后缩小。什么好主意吗?或者在jquery中是可能的?

(function ($) {"使用严格";

    // Start Documentation
    $(document).ready(function () {

        //  About Us Title Text
        $('.about_us_img,.about_us_txt').mouseover(function () {
            {
                $('.about_us_img').animate({
                    width: "216px"
                }, 400);
                $('.about_us_txt').css({
                    color: '#49968b'
                });
                $('.about_us_txt').animate({
                    fontSize: newSizeAU
                }, 300);
                $('.about_us_img').attr("src", AboutHut);
                $(this).fadeTo('300', 0.9);
            }
        });
        $('.about_us_img,.about_us_txt').mouseout(function () {
            {
                $('.about_us_img').animate({
                    width: "196px"
                }, 400);
                $('.about_us_txt').css({
                    color: '#000'
                });
                $('.about_us_txt').animate({
                    fontSize: oldSizeAU
                }, 300);
                $(this).fadeTo('300', 1);
                $('.about_us_img ').attr("src", OrigHut);
            }
        });
        var oldSizeAU = parseFloat($('.about_us_txt').css('font-size'));
        var newSizeAU = oldSizeAU * 1.1;

        //Our Project

        $('.our_project_img,.our_project_txt').mouseover(function () {
            {
                $('.our_project_img').animate({
                    width: "216px"
                }, 400);
                $('.our_project_txt').css({
                    color: '#b26c64'
                });
                $('.our_project_txt').animate({
                    fontSize: newSizePR
                }, 300);
                $('.our_project_img').attr("src", ProjectHut);
                $(this).fadeTo('300', 0.9);
            }
        });
        $('.our_project_img,.our_project_txt').mouseout(function () {
            {
                $('.our_project_img').animate({
                    width: "196px"
                }, 400);
                $('.our_project_txt').css({
                    color: '#000'
                });
                $('.our_project_txt').animate({
                    fontSize: oldSizePR
                }, 300);
                $(this).fadeTo('300', 1);
                $('.our_project_img').attr("src", OrigHut);
            }
        });
        var oldSizePR = parseFloat($('.our_project_txt').css('font-size'));
        var newSizePR = oldSizePR * 1.1;

        //My Profile

        $('.my_profile_img,.my_profile_txt').mouseover(function () {
            {
                $(this).fadeTo('300', 0.9);
                $('.my_profile_img').animate({
                    width: "216px"
                }, 400);
                $('.my_profile_txt').css({
                    color: '#8db262'
                });
                $('.my_profile_txt').animate({
                    fontSize: newSize
                }, 300);
                $('.my_profile_img').attr("src", ProfileHut);
            }
        });
        $('.my_profile_img,.my_profile_txt').mouseout(function () {
            {
                $('.my_profile_img').animate({
                    width: "196px"
                }, 400);
                $('.my_profile_txt').css({
                    color: '#000'
                });
                $('.my_profile_txt').animate({
                    fontSize: oldSize
                }, 300);
                $(this).fadeTo('300', 1);
                $('.my_profile_img').attr("src", OrigHut);
            }
        });



        var oldSize = parseFloat($('.my_profile_txt').css('font-size'));
        var newSize = oldSize * 1.1;
        /****
$('.my_profile_img,.my_profile_txt').mouseover(function () {

    $('.my_profile_img,.my_profile_txt').fadeTo('slow', 0.8, function () {
        $('.my_profile_img').animate({
            width: newWidthSize
        }, 500);
        $('.my_profile_txt').animate({
            fontSize: NewSize
        }, 300);

        $(this).fadeTo('200', 1);
        $('.my_profile_img').attr('src', ProfileHut);

    });
});
$('.my_profile_img,.my_profile_txt').mouseout(function () {
    $('.my_profile_img').animate({
        width: oldWidthSize
    }, 500);
    $('.my_profile_txt').animate({
        fontSize: oldSize
    }, 300);
    $(this).fadeTo('300', 0.9, function () {
        $('.my_profile_img').attr('src', OrigHut);
        $(this).fadeTo('300', 1);
    });
});
var oldWidthSize = parseFloat($('.my_profile_img').css('width'));
var newWidthSize = oldWidthSize * 1.1;
**/

        // End Ready Documentation
    });

})(jQuery);

jQuery不支持彩色动画。然而,jQuery UI有一个处理颜色动画的插件(参见UI页面中的颜色动画:http://jqueryui.com/animate/)。您需要首先安装jQuery UI并使用插件,您可以在这里找到:https://github.com/jquery/jquery-color/

插件页面上也有一个很好的例子

一旦你安装了插件,它应该很容易动画颜色。下面的代码片段摘自插件文档,应该能让你了解它是如何工作的:

<!DOCTYPE html>
<html>
<head>
<style>
div {
  background-color: #bada55;
  width: 100px;
  border: 1px solid green;
}
</style>
<script src="http://code.jquery.com/jquery-1.6.1.min.js"></script> //jQuery UI
<script src="jquery.color.min.js"></script> //plugin
</head>
<body>
<button id="go">Simple</button>
<button id="sat">Desaturate</button>
<div id="block">Hello!</div>
<script>
jQuery("#go").click(function(){
  jQuery("#block").animate({
      backgroundColor: "#abcdef"
  }, 1500 );
});
jQuery("#sat").click(function(){
  jQuery("#block").animate({
      backgroundColor: jQuery.Color({ saturation: 0 })
  }, 1500 );
});
</script>
</body>
</html>

似乎你想在两个图像之间过渡,而不是改变单个图像的颜色,是这样吗?

这个小提琴(点击小黄人)使小黄人扩大,然后消失,然后被米老鼠取代。如果这是你想要的一般的东西,你可以有两个图像,完全相同的大小,但不同的颜色,并在小提琴演奏的大小。

JS

$( ".imagediv" ).click(function(){
  $( "#minion" ).animate({
                          height: 400,
                          width: 300
                          }, 3000,
                         function() {
                                 $( "#minion" ).animate({
                                                opacity: 0
                                                         }, 1000,
                          function() {
                                      $('.imagediv').html( $('.hiddendiv img').clone() );
                                      });
                                     });
});//end click