悬停/鼠标悬停时更改颜色和比例?

发布于 2024-11-04 20:38:32 字数 283 浏览 2 评论 0原文

我正在尝试创建很小的灰色按钮,直到鼠标悬停在上面为止,然后它们就会变大并着色。

我用过 Soh Tanaka 很棒的灰度教程 - 但我不知道如何添加额外的参数,使图像在鼠标悬停时也变大。

http://www.sohtanaka.com/web-design/examples/将鼠标悬停在技巧/

任何帮助表示赞赏!

I'm trying to create buttons that are small, and grey until moused over- then they become large and colored.

I've used Soh Tanaka's awesome greyscale tutorial-
but I can't figure out how to add the additional parameter of having the images also get bigger when moused over.

http://www.sohtanaka.com/web-design/examples/hover-over-trick/

any help is appreciated!!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

决绝 2024-11-11 20:38:33

只需设置宽度、高度、顶部、左侧和边距的动画即可。这是 http://www.sohtanaka 的片段。 com/web-design/fancy-thumbnail-hover-effect-w-jquery/

 $("ul.thumb li").hover(function() {
        $(this).css({'z-index' : '10'}); /*Add a higher z-index value so this image stays on top*/ 
        $(this).find('img').addClass("hover").stop() /* Add class of "hover", then stop animation queue buildup*/
            .animate({
                marginTop: '-110px', /* The next 4 lines will vertically align this image */ 
                marginLeft: '-110px',
                top: '50%',
                left: '50%',
                width: '174px', /* Set new width */
                height: '174px', /* Set new height */
                padding: '20px'
            }, 200); /* this value of "200" is the speed of how fast/slow this hover animates */

        } , function() {
        $(this).css({'z-index' : '0'}); /* Set z-index back to 0 */
        $(this).find('img').removeClass("hover").stop()  /* Remove the "hover" class , then stop animation queue buildup*/
            .animate({
                marginTop: '0', /* Set alignment back to default */
                marginLeft: '0',
                top: '0',
                left: '0',
                width: '100px', /* Set width back to default */
                height: '100px', /* Set height back to default */
                padding: '5px'
            }, 400);
    });

Just animate width, height, top, left and margins. Here's a snippet from http://www.sohtanaka.com/web-design/fancy-thumbnail-hover-effect-w-jquery/

 $("ul.thumb li").hover(function() {
        $(this).css({'z-index' : '10'}); /*Add a higher z-index value so this image stays on top*/ 
        $(this).find('img').addClass("hover").stop() /* Add class of "hover", then stop animation queue buildup*/
            .animate({
                marginTop: '-110px', /* The next 4 lines will vertically align this image */ 
                marginLeft: '-110px',
                top: '50%',
                left: '50%',
                width: '174px', /* Set new width */
                height: '174px', /* Set new height */
                padding: '20px'
            }, 200); /* this value of "200" is the speed of how fast/slow this hover animates */

        } , function() {
        $(this).css({'z-index' : '0'}); /* Set z-index back to 0 */
        $(this).find('img').removeClass("hover").stop()  /* Remove the "hover" class , then stop animation queue buildup*/
            .animate({
                marginTop: '0', /* Set alignment back to default */
                marginLeft: '0',
                top: '0',
                left: '0',
                width: '100px', /* Set width back to default */
                height: '100px', /* Set height back to default */
                padding: '5px'
            }, 400);
    });
故事还在继续 2024-11-11 20:38:33
    Try this one make Two class 
    .before_hover{
         width:10px;
         height:10px;
     }
    .on_hover{
         width:10px !important;
         height:10px !important;
     } 

  Jquery 
   $(document).ready(function(){
      $('ul li').hover(function(){
       $(this).siblings().removeClass('on_hover'); 
       $(this).addClass('on_hover');
      },
      function(){
      });

   });

    you can make required changes in css.
    Try this one make Two class 
    .before_hover{
         width:10px;
         height:10px;
     }
    .on_hover{
         width:10px !important;
         height:10px !important;
     } 

  Jquery 
   $(document).ready(function(){
      $('ul li').hover(function(){
       $(this).siblings().removeClass('on_hover'); 
       $(this).addClass('on_hover');
      },
      function(){
      });

   });

    you can make required changes in css.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文