Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jquery Slide Animation on hover

I am trying to implement a Jquery Hover function on my Company Logo. I want to achieve this :

Hover Effect using Jquery

However, I had achieved THIS

I used the following logic :

$(".m1").hover(function() {
        dir = !dir;
        r = dir? -50 : 0;
        t = dir? 50 : 0;

        $(".slide").stop().animate({left: r+'px'}, 300);

    });

You can check my JS Fiddle here : http://jsfiddle.net/Jiteen/xZ6Hv/ Any sort of Help or Suggestion is Appreciated.

like image 752
Jiteen Avatar asked Jul 09 '26 08:07

Jiteen


1 Answers

How about the below as a starting point? No need for JS!

Demo Fiddle

HTML

<div>
    <div href="#" class="word" data-text="edia">M</div>
    <div href="#" class="word" data-text="antra">M</div>
</div>

CSS

.word {
    display:inline-block;
    font-size:1em;
    line-height:1;
    position:relative;
    font-size:50px;
}
.word:first-child {
    color:orange;
}
.word:last-child {
    color:grey;
}
.word:after {
    content:attr(text);
    position:relative;
    display:inline-block;
    overflow:hidden;
    max-width:0;
    color:black;
    font-size:20px;
    transition:max-width .5s ease-in;
}
div:hover .word:after {
    max-width:40px;
}
like image 169
SW4 Avatar answered Jul 11 '26 18:07

SW4