Code showing the smooth movement of text links between left and right

Source: Internet
Author: User


Of course, it will be great to take some time to change it. I will post the code below:

Html code:

The code is as follows: Copy code

<Div> <a href = "#1"> Test </a> </div>

Css code:

The code is as follows: Copy code

. Test a {background-color: #446CB3; color: # ffffff; padding: 10px; text-decoration: none;
-Webkit-transition: margin 0.2 s transfer-out;
-Moz-transition: margin 0.2 s outgoing-out;
-Khtml-transition: margin 0.2 s transfer-out ;}
A: hover {margin-left: 10px ;}

Of course, we need to know that css3 animation is not compatible with browsers earlier than ie10, so this effect is not very effective in earlier versions of the IE kernel, but this effect is very simple to implement. We can combine jquery

Of course, we know that css3 animation is not compatible with browsers earlier than ie10, so we can use jq code to implement it. The specific code is:

The code is as follows: Copy code

$ (Function (){
$ ("A"). hover (function (){
$ (This ). stop (). animate ({"margin-left": "10px", "text-shadow": "2px 2px 10px #333333 & Prime ;}," fast ");

}, Function (){
$ (This). stop (). animate ({"margin-left": "0px"}, "fast ");
});
});

You may wonder why there is a position: relative in css? In fact, this is another method of writing. The jq code is as follows:

The code is as follows: Copy code

$ (Function (){
$ ("A"). hover (function (){

$ (This). stop (). animate ({"left": "10px"}, 300 );
}, Function (){
$ (This). stop (). animate ({"left": "0px"}, 300 );
});
});

Is it very simple? It is worth trying.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.