HTML Color Codes: Red to Yellow to Green

前端 未结 13 1218
栀梦
栀梦 2020-12-23 11:16

I would like to come up with as many HEX HTML values to have a smooth color gradient from red to green:

I would like this to be similar to the following: http://ww

13条回答
  •  轮回少年
    2020-12-23 12:02

    Nowadays all modern browsers support color gradients in CSS which allow totally smooth gradients over any width/height. However, still not all browsers support the official CSS linear-gradient, so in order to support all browsers, use the following CSS class:

    .gradient {
        background:    -moz-linear-gradient(left, red, yellow, green); /* FF3.6+ */
        background:        -webkit-gradient(linear, left top, right top, color-stop(0%, red), color-stop(50%, yellow), color-stop(100%, green)); /* Chrome,Safari4+ */
        background: -webkit-linear-gradient(left, red, yellow, green); /* Chrome10+,Safari5.1+ */
        background:      -o-linear-gradient(left, red, yellow, green); /* Opera 11.10+ */
        background:     -ms-linear-gradient(left, red, yellow, green); /* IE10+ */
        background:         linear-gradient(to right, red, yellow, green); /* W3C */
    }
    

    For further reference of the CSS gradient functions, see the following articles in the Mozilla Developer Network:

    • linear-gradient (also lists the supported browsers)
    • Using CSS gradients

    A very good web site to quickly generate completely customized color gradients for all browsers is the Ultimate CSS Gradient Generator.

提交回复
热议问题