一点一点地使背景颜色变暗的简单方法

时间:2015-07-29 08:41:16

标签: css3 background gradient fullpage.js

我正在使用fullpage.js创建一个响应式的全页网站,我有7个部分,我的目标之一是创建一个从white开始的背景颜色,然后每当用户向下滚动到第7节时希望它变得黑暗。实际上我可以做到这一点,但由于获得了正确的黑暗量,我需要花费很多时间,还值得一提的是我使用this来创建渐变背景。

简而言之,我想做以下事情:

  1. 我想加强从白色到黑暗的颜色。
  2. 如果可能,你可以调整吗?让我也想要一个从白色到深红色,从蓝色到白色等的背景。
  3. 到目前为止,我正在使用此代码将背景放在我网站的每个部分,因为您可以看到它很难维护,而且代码似乎很大。我可以做A = White然后B = Gray这样的功能然后该功能会自动将它从白色渐变到灰色吗?

    / *第1节 * --------------------------------------- * /

    SECTION1 {

    background: -moz-linear-gradient(top,  rgba(255,255,255,1) 37%, rgba(255,255,255,0.55) 65%, rgba(187,187,187,0.05) 96%, rgba(178,178,178,0.05) 100%);
    background: -webkit-gradient(linear, left top, left bottom, color-stop(37%,rgba(255,255,255,1)), color-stop(65%,rgba(255,255,255,0.55)), color-stop(96%,rgba(187,187,187,0.05)), color-stop(100%,rgba(178,178,178,0.05)));
    background: -webkit-linear-gradient(top,  rgba(255,255,255,1) 37%,rgba(255,255,255,0.55) 65%,rgba(187,187,187,0.05) 96%,rgba(178,178,178,0.05) 100%);
    background: -o-linear-gradient(top,  rgba(255,255,255,1) 37%,rgba(255,255,255,0.55) 65%,rgba(187,187,187,0.05) 96%,rgba(178,178,178,0.05) 100%);
    background: -ms-linear-gradient(top,  rgba(255,255,255,1) 37%,rgba(255,255,255,0.55) 65%,rgba(187,187,187,0.05) 96%,rgba(178,178,178,0.05) 100%);
    background: linear-gradient(to bottom,  rgba(255,255,255,1) 37%,rgba(255,255,255,0.55) 65%,rgba(187,187,187,0.05) 96%,rgba(178,178,178,0.05) 100%);
    filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffffff', endColorstr='#0db2b2b2',GradientType=0 );
    

    } / *第2节 * --------------------------------------- * /

    第2节{

    background: -moz-linear-gradient(top,  rgba(206,206,206,0.15) 0%, rgba(207,207,207,0.15) 10%, rgba(216,216,216,1) 96%, rgba(216,216,216,1) 100%);
    background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(206,206,206,0.15)), color-stop(10%,rgba(207,207,207,0.15)), color-stop(96%,rgba(216,216,216,1)), color-stop(100%,rgba(216,216,216,1)));
    background: -webkit-linear-gradient(top,  rgba(206,206,206,0.15) 0%,rgba(207,207,207,0.15) 10%,rgba(216,216,216,1) 96%,rgba(216,216,216,1) 100%);
    background: -o-linear-gradient(top,  rgba(206,206,206,0.15) 0%,rgba(207,207,207,0.15) 10%,rgba(216,216,216,1) 96%,rgba(216,216,216,1) 100%);
    background: -ms-linear-gradient(top,  rgba(206,206,206,0.15) 0%,rgba(207,207,207,0.15) 10%,rgba(216,216,216,1) 96%,rgba(216,216,216,1) 100%);
    background: linear-gradient(to bottom,  rgba(206,206,206,0.15) 0%,rgba(207,207,207,0.15) 10%,rgba(216,216,216,1) 96%,rgba(216,216,216,1) 100%);
    filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#26cecece', endColorstr='#d8d8d8',GradientType=0 );
    

    } / *第3节 * --------------------------------------- * /

    SECTION3 {

    background: rgb(226,226,226);
    background: -moz-linear-gradient(top,  rgba(226,226,226,1) 0%, rgba(201,201,201,1) 69%);
    background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(226,226,226,1)), color-stop(69%,rgba(201,201,201,1)));
    background: -webkit-linear-gradient(top,  rgba(226,226,226,1) 0%,rgba(201,201,201,1) 69%);
    background: -o-linear-gradient(top,  rgba(226,226,226,1) 0%,rgba(201,201,201,1) 69%);
    background: -ms-linear-gradient(top,  rgba(226,226,226,1) 0%,rgba(201,201,201,1) 69%);
    background: linear-gradient(to bottom,  rgba(226,226,226,1) 0%,rgba(201,201,201,1) 69%);
    filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#e2e2e2', endColorstr='#c9c9c9',GradientType=0 );
    

    }

    / *第4节 * --------------------------------------- * /

    section4 {

    background: rgb(186,186,186);
    background: -moz-linear-gradient(top,  rgba(186,186,186,1) 0%, rgba(147,147,147,1) 32%);
    background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(186,186,186,1)), color-stop(32%,rgba(147,147,147,1)));
    background: -webkit-linear-gradient(top,  rgba(186,186,186,1) 0%,rgba(147,147,147,1) 32%);
    background: -o-linear-gradient(top,  rgba(186,186,186,1) 0%,rgba(147,147,147,1) 32%);
    background: -ms-linear-gradient(top,  rgba(186,186,186,1) 0%,rgba(147,147,147,1) 32%);
    background: linear-gradient(to bottom,  rgba(186,186,186,1) 0%,rgba(147,147,147,1) 32%);
    filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#bababa', endColorstr='#939393',GradientType=0 );
    

    } / *第5节 * --------------------------------------- * /

    section5 {

    background: rgb(186,186,186);
    background: -moz-linear-gradient(top,  rgba(186,186,186,1) 0%, rgba(147,147,147,1) 32%);
    background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(186,186,186,1)), color-stop(32%,rgba(147,147,147,1)));
    background: -webkit-linear-gradient(top,  rgba(186,186,186,1) 0%,rgba(147,147,147,1) 32%);
    background: -o-linear-gradient(top,  rgba(186,186,186,1) 0%,rgba(147,147,147,1) 32%);
    background: -ms-linear-gradient(top,  rgba(186,186,186,1) 0%,rgba(147,147,147,1) 32%);
    background: linear-gradient(to bottom,  rgba(186,186,186,1) 0%,rgba(147,147,147,1) 32%);
    filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#bababa', endColorstr='#939393',GradientType=0 );
    

    }

    / *第6节 * --------------------------------------- * /

    section6 {

    background: rgb(186,186,186);
    background: -moz-linear-gradient(top,  rgba(186,186,186,1) 0%, rgba(147,147,147,1) 32%);
    background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(186,186,186,1)), color-stop(32%,rgba(147,147,147,1)));
    background: -webkit-linear-gradient(top,  rgba(186,186,186,1) 0%,rgba(147,147,147,1) 32%);
    background: -o-linear-gradient(top,  rgba(186,186,186,1) 0%,rgba(147,147,147,1) 32%);
    background: -ms-linear-gradient(top,  rgba(186,186,186,1) 0%,rgba(147,147,147,1) 32%);
    background: linear-gradient(to bottom,  rgba(186,186,186,1) 0%,rgba(147,147,147,1) 32%);
    filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#bababa', endColorstr='#939393',GradientType=0 );
    

    }

    / *第7节 * --------------------------------------- * /

    {章第7

    background: rgb(186,186,186);
    background: -moz-linear-gradient(top,  rgba(186,186,186,1) 0%, rgba(147,147,147,1) 32%);
    background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(186,186,186,1)), color-stop(32%,rgba(147,147,147,1)));
    background: -webkit-linear-gradient(top,  rgba(186,186,186,1) 0%,rgba(147,147,147,1) 32%);
    background: -o-linear-gradient(top,  rgba(186,186,186,1) 0%,rgba(147,147,147,1) 32%);
    background: -ms-linear-gradient(top,  rgba(186,186,186,1) 0%,rgba(147,147,147,1) 32%);
    background: linear-gradient(to bottom,  rgba(186,186,186,1) 0%,rgba(147,147,147,1) 32%);
    filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#bababa', endColorstr='#939393',GradientType=0 );
    

    }

0 个答案:

没有答案