0

I have the following jquery code that does what I require:

$("#myele").animate({left: "-120%", height: 0});

How could I translate this code into a css3 transition?

1
  • your code wouldn't work, this one might $("#myele").animate ({left: "-120%", height: 0},duration) Commented Jun 19, 2014 at 13:49

2 Answers 2

1

You can try this but i don't know why css when you have done it this way

#myele:hover{
    left:+="-120%";
    height:0;
}
Sign up to request clarification or add additional context in comments.

1 Comment

are you using less? this is not pure css.
1

This should work, given that the object you're animating has an initial height (other than height: auto;) If that's not the case, you could use transform: scale(0); instead of height

@-webkit-keyframes myanimation {
    100% { 
        left: -120%;
        height: 0;
    }
}

@-moz-keyframes myanimation {
    100% { 
        left: -120%;
        height: 0;
    }
}

@-o-keyframes myanimation {
    100% { 
        left: -120%;
        height: 0;
    }
}

@keyframes myanimation {
    100% { 
        left: -120%;
        height: 0;
    }
}

#myele {
    -webkit-animation: myanimation .5s;
    -moz-animation:    myanimation .5s;
    -o-animation:      myanimation .5s;
    animation:         myanimation .5s;
}

Comments

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.