Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/39.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery 在图像上淡入文本_Jquery_Css - Fatal编程技术网

Jquery 在图像上淡入文本

Jquery 在图像上淡入文本,jquery,css,Jquery,Css,有两件事似乎不合适 我希望能够悬停较大的DIV,以便将较小的DIV带入视图 目前,它只在您将鼠标悬停在较小的DIV上时工作。 2.当我停止悬停时,较小的DIV不会消失 <div class="one"> <div class="two"></div> </div> <div class="one"> <div class="two"></div> </div> 这是因为您正在选择

有两件事似乎不合适

  • 我希望能够悬停较大的DIV,以便将较小的DIV带入视图
  • 目前,它只在您将鼠标悬停在较小的DIV上时工作。 2.当我停止悬停时,较小的DIV不会消失

    <div class="one">
        <div class="two"></div>
    </div>
    
    <div class="one">
        <div class="two"></div>
    </div>
    

    这是因为您正在选择较小的div标记

    $(function() {
        $(".two").hide();
        $(".one").hover(function() {
            $('.two', this).fadeIn(200);
        }, function() {
            $('.two', this).fadeOut(200);
        });
    });
    


    你应该瞄准较大的div,
    .one
    ,然后在
    的上下文中更改较小的div,
    .two
    ,每当鼠标悬停
    .one
    。当从可见淡入不可见时,大部分时间都可以使用fadeIn/Out,只需在CSS中将元素设置为
    display:none

    $(function(){
        $('.one').on({
            mouseenter: function() {
                $(".two", this).fadeIn(200);
            },
            mouseleave: function() {
                $(".two", this).fadeOut(200);        
            }
        });
    });​
    


    很抱歉,这篇文章格式不正确:)
    $(function() {
        $(".two").hide();
        $(".one").hover(function() {
            $('.two', this).fadeIn(200);
        }, function() {
            $('.two', this).fadeOut(200);
        });
    });
    
    $(function(){
        $('.one').on({
            mouseenter: function() {
                $(".two", this).fadeIn(200);
            },
            mouseleave: function() {
                $(".two", this).fadeOut(200);        
            }
        });
    });​
    
    $(".one").on('mouseenter mouseleave',function ( e ) {
          var fade = e.type=='mouseenter'?
          $('.two', this).stop().fadeTo(200, 1):
          $('.two', this).stop().fadeTo(200, 0);
    });