0

$(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">
		<div class="feature-icon1"><i class="fa fa-balance-scale"></i></div>
		<div class="feature-content">Every one is equal before Law</div>
</div>

This is my code here iam using hover function but it's not working fine. when I mouseout also box-shadow remains same what might be the problem. thanks

1 Answer 1

2

Here is a working demo.

$(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>

The problem you had was that you did not handle the mouse-out event.

Hope this helps!

Sign up to request clarification or add additional context in comments.

2 Comments

thanks. actually, I don't want to increase the lines of codes.Instead of a mouse event, any other possibilities are there do you know.
@MerajKhan I believe you cannot achieve what you want without writing extra code. The computer doesn't know what you want it to do unless you tell it by writing code.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.