2017-09-13 7 views
0

mouseInまたはマウスアウト

$(document).ready(function(){ 
 
    var color = $('.feature-icon1').css('color','#00a6ff'); 
 
    $('.box-style1').hover(function(){ 
 
    $(this).css({ 
 
     'box-shadow' : '0px 13px 40px 0px #00a6ff', 
 
     'background-color': 'color', 
 
     'transform': 'translateY(-2px)' 
 
    }); 
 
    }); 
 
});
.feature-box { 
 
    padding-top: 30px; 
 
    display: inline-block; 
 
    position: relative; 
 
    text-align: center; 
 
    width: 100%; 
 
    border-radius: 4px; 
 
    margin: 0 9px; 
 
    transition: all .7s ease-out; 
 
    font-family: Arial; 
 
} 
 
.box-style1 {width: 100%;height: auto;} 
 
.box-style2 {width: 100%;height: auto;} 
 
.box-style3 {width: 100%;height: auto;} 
 
.box-style4 {width: 100%;height: auto;} 
 
.feature-icon1 { 
 
    font-size: 40px; 
 
    margin: 0 0 15px; 
 
}
<script src="https://use.fontawesome.com/a2e210f715.js"></script> 
 
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script> 
 
<div class="feature-box box-style1"> 
 
\t \t <div class="feature-icon1"><i class="fa fa-balance-scale"></i></div> 
 
\t \t <div class="feature-content">Every one is equal before Law</div> 
 
</div>

は、これは私のここでのコードホバー機能を使用してIAMですが、それがうまく働いていないときにCSSを変更するjQueryのホバーイベントを使用します。私もmouseoutもボックスシャドウが問題の可能性があるものと同じままです。ありがとう

答えて

2

ここにデモがあります。

$(document).ready(function() { 
 
    var color = $('.feature-icon1').css('color', '#00a6ff'); 
 
    $('.box-style1').hover(function() { 
 
     $(this).css({ 
 
     'box-shadow': '0px 13px 40px 0px #00a6ff', 
 
     'background-color': 'color', 
 
     'transform': 'translateY(-2px)' 
 
     }); 
 
    }, 
 
    function() { 
 
     $(this).css({ 
 
     'box-shadow': 'none', 
 
     'background-color': 'color', 
 
     'transform': 'translateY(-2px)' 
 
     }); 
 
    }); 
 
});
.feature-box { 
 
    padding-top: 30px; 
 
    display: inline-block; 
 
    position: relative; 
 
    text-align: center; 
 
    width: 100%; 
 
    border-radius: 4px; 
 
    margin: 0 9px; 
 
    transition: all .7s ease-out; 
 
    font-family: Arial; 
 
} 
 

 
.box-style1 { 
 
    width: 100%; 
 
    height: auto; 
 
} 
 

 
.box-style2 { 
 
    width: 100%; 
 
    height: auto; 
 
} 
 

 
.box-style3 { 
 
    width: 100%; 
 
    height: auto; 
 
} 
 

 
.box-style4 { 
 
    width: 100%; 
 
    height: auto; 
 
} 
 

 
.feature-icon1 { 
 
    font-size: 40px; 
 
    margin: 0 0 15px; 
 
}
<script src="https://use.fontawesome.com/a2e210f715.js"></script> 
 
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script> 
 
<div class="feature-box box-style1"> 
 
    <div class="feature-icon1"><i class="fa fa-balance-scale"></i></div> 
 
    <div class="feature-content">Every one is equal before Law</div> 
 
</div>

あなたが持っていた問題は、あなたがmouse-outイベントを処理していないということでした。

希望すると便利です。

+0

ありがとうございました。実際には、私はコード行を増やしたくありません。マウスイベントの代わりに、他の可能性があります。 –

+0

@MerajKhan私はあなたが余分なコードを書くことなくあなたが望むものを達成することはできないと信じています。あなたがコードを書くことによってそれを伝えない限り、コンピュータはあなたが望むものが何かを知りません。 –

+0

ok.t​​hatが役に立ちました。 –

関連する問題