The colorful gradient effect of JS clip whimsy

Source: Internet
Author: User

Previously, the clip attribute was used to splice up and down two half different colors of text.
Colorful gradient words, compatible with all mainstream browsers.
Only the colorful () function is really useful in page JS: CopyCode The Code is as follows: function colorful (OBJ, Font, R, G, B, type ){
VaR boxobj;
If (typeof (OBJ) = "string" | typeof (OBJ) = "Number "){
Boxobj = Document. getelementbyid (OBJ );
} Else {
Boxobj = OBJ;
}
Boxobj. innerhtml = "<a href = '#'>" + font + "</a> ";
VaR num = boxobj. getelementsbytagname ("A") [0]. scrollwidth;
Boxobj. innerhtml = "";
For (VAR I = 0; I <= num; I ++ ){
VaR J = I + 1;
VaR c = math. Round (255/num * I );
Switch (number (type )){
Case 0: r = C; G = C; B = C; break;
Case 1: r = C; break;
Case 2: g = C; break;
Case 3: B = C; break;
}
VaR iobj = Document. createelement ("");
Iobj. innerhtml = font;
Iobj. style. Clip = "rect (Auto" + J + "PX auto" + I + "PX )";
Iobj. style. color = "RGB (" + R + "," + G + "," + B + ")";
Iobj. href = "#";
Boxobj. appendchild (iobj );
}
}

Xmlns = "http://www.w3.org/1999/xhtml">


CSS colorful gradient words

Text:
R value:

Initializes the R value in the RGB color.

G value:

Initialize the G value in the RGB color.

B value:

Initializes the B value in the RGB color.

Gradient mode: Grayscale gradientVariable R ValueChange G valueChange B value

The corresponding value is forced to be 0 ~ Change between 255

Gradient coloring

Designed by silence. For details, refer to the source.

Http://www.silentash.com /? Id = 109

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.