Return the JS Code of the color of the cyclic gradient with an incremental number.

Source: Internet
Author: User

The function is as follows: CopyCodeThe Code is as follows: function GCL (I ){
VaR F = parseint (I % 15)/5 );
I = I % 15% 5;
Switch (f ){
Case 0: Return "#" + CS2 (255-i * 51) + CS2 (I * 51) + "00 ";
Case 1: Return "#00" + CS2 (255-i * 51) + CS2 (I * 51 );
Case 2: Return "#" + CS2 (I * 51) + "00" + CS2 (255-i * 51 );
}
}
Function CS2 (I ){
VaR S = I. tostring (16 );
Return ("00" + S). substr (S. Length );
}

You can use GCL to return the gradient color from red to green to blue. Gradient effect:

For example, in the following application, you can use this function to gradient the background color of the hyperlink:Home page <br/>
[Ctrl + A select all Note: If you need to introduce external JS, You need to refresh it to execute]

This function can also produce more detailed color changes. If you are interested, try it.

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.