Html 如何在单个按钮上使用2个渐变

Html 如何在单个按钮上使用2个渐变,html,css,Html,Css,我必须应用梯度按钮与以下事情 对于按钮的正常状态,我想使用 对于按钮的悬停状态,我想使用 对于on单击按钮的状态,我想使用 我尝试了以下代码 HTML <button type="button" class="button_color"> Make Payment 请帮我解决这个问题。您必须使用伪类。 悬停状态的css将被写入“按钮:悬停{desierd css}” 按键状态的css将被写入“按钮:活动{desierd css}” 下面是一个

我必须应用梯度按钮与以下事情

  • 对于按钮的正常状态,我想使用
  • 对于按钮的悬停状态,我想使用
  • 对于on单击按钮的状态,我想使用
  • 我尝试了以下代码

    HTML

    <button type="button" class="button_color">
    Make Payment
    

    请帮我解决这个问题。

    您必须使用伪类。 悬停状态的css将被写入“按钮:悬停{desierd css}”

    按键状态的css将被写入“按钮:活动{desierd css}”

    下面是一个描述该问题的链接

    希望它有帮助

    您可以试试这个:

     background: linear-gradient(#0069A6,#0078C0,#005F96,#004085);
    
    。按钮\u颜色{
    高度:40px;
    边界半径:10px;
    颜色:白色;
    背景:线性梯度(#0069A6,#0078C0,#005F96,#004085);
    }
    
    
    付款
    您可以使用css选择器进行以下操作:

    <style>
    .button_color:hover{
        background: linear-gradient(#01152D 10%,#0078C0 100%);
    }
    .button_color:active{
        background: linear-gradient(#0000ff 10%,#ffffff 100%);
    }
    .button_color{
        height:40px;
        border-radius:10px;
        color:white;
        background: linear-gradient(#ff002D 10%,#00eeC0 100%);
    }
    </style>
    
    <button type="button" class="button_color">
    Make Payment
    </button>
    
    
    .按钮颜色:悬停{
    背景:线性梯度(#01152D 10%,#0078C0 100%);
    }
    .按钮颜色:活动{
    背景:线性梯度(10%,100%);
    }
    .按钮颜色{
    高度:40px;
    边界半径:10px;
    颜色:白色;
    背景:线性梯度(#ff002D 10%,#00eeC0 100%);
    }
    付款
    
    用法很简单:,你可以通过谷歌搜索找到其他选择器。您还可以更改类的颜色、边框和任何属性,所有这些都将自动完成

    在主类中添加您想要的任何更改,当选择器激活时,您的css将被替换

    请自己改变颜色,这只是一个演示如何做你的工作。你也不需要包括到顶端,等等。你必须用百分比。这意味着颜色的开始

    在代码中,您将开始和结束设置为10%,这对于双色渐变是错误的

    例如,对于3种颜色渐变,可以使用:(红色10%,绿色50%,蓝色100%)

    查看

    我不知道你是怎么想的,所以我为你创建了带有硬中断的渐变:

    .button_color{
    height:40px;
    border-radius:10px;
    color:white;
    background: #0069a6;
    background: -moz-linear-gradient(top, #0069a6 0%, #1e5799 50%, #0078c0 50%, #0078c0 51%, #005f96 100%);
    background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#0069a6), color-stop(50%,#1e5799), color-stop(50%,#0078c0), color-stop(51%,#0078c0), color-stop(100%,#005f96));
    background: -webkit-linear-gradient(top, #0069a6 0%,#1e5799 50%,#0078c0 50%,#0078c0 51%,#005f96 100%);
    background: -o-linear-gradient(top, #0069a6 0%,#1e5799 50%,#0078c0 50%,#0078c0 51%,#005f96 100%);
    background: -ms-linear-gradient(top, #0069a6 0%,#1e5799 50%,#0078c0 50%,#0078c0 51%,#005f96 100%);
    background: linear-gradient(to bottom, #0069a6 0%,#1e5799 50%,#0078c0 50%,#0078c0 51%,#005f96 100%);
    filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#0069a6', endColorstr='#005f96',GradientType=0 );
    }
    .button_color:hover{
    background: #02356a;
    background: -moz-linear-gradient(top, #02356a 0%, #1e5799 50%, #0078c0 50%, #0078c0 50%, #01152d 51%, #002147 100%);
    background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#02356a), color-stop(50%,#1e5799), color-stop(50%,#0078c0), color-stop(50%,#0078c0), color-stop(51%,#01152d), color-stop(100%,#002147));
    background: -webkit-linear-gradient(top, #02356a 0%,#1e5799 50%,#0078c0 50%,#0078c0 50%,#01152d 51%,#002147 100%);
    background: -o-linear-gradient(top, #02356a 0%,#1e5799 50%,#0078c0 50%,#0078c0 50%,#01152d 51%,#002147 100%);
    background: -ms-linear-gradient(top, #02356a 0%,#1e5799 50%,#0078c0 50%,#0078c0 50%,#01152d 51%,#002147 100%);
    background: linear-gradient(to bottom, #02356a 0%,#1e5799 50%,#0078c0 50%,#0078c0 50%,#01152d 51%,#002147 100%);
    filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#02356a', endColorstr='#002147',GradientType=0 );
    }
    .button_color:active{
    background: #004085;
    background: -moz-linear-gradient(top, #004085 0%, #005f96 50%, #0078c0 50%, #0078c0 50%, #0069a6 51%, #0078c0 100%);
    background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#004085), color-stop(50%,#005f96), color-stop(50%,#0078c0), color-stop(50%,#0078c0), color-stop(51%,#0069a6), color-stop(100%,#0078c0));
    background: -webkit-linear-gradient(top, #004085 0%,#005f96 50%,#0078c0 50%,#0078c0 50%,#0069a6 51%,#0078c0 100%);
    background: -o-linear-gradient(top, #004085 0%,#005f96 50%,#0078c0 50%,#0078c0 50%,#0069a6 51%,#0078c0 100%);
    background: -ms-linear-gradient(top, #004085 0%,#005f96 50%,#0078c0 50%,#0078c0 50%,#0069a6 51%,#0078c0 100%);
    background: linear-gradient(to bottom, #004085 0%,#005f96 50%,#0078c0 50%,#0078c0 50%,#0069a6 51%,#0078c0 100%);
    filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#004085', endColorstr='#0078c0',GradientType=0 );
    }
    
    如果这不是您所期望的,请使用渐变生成器亲自尝试

    .button_color{
        height:40px;
        border-radius:10px;
        color:white;
        background: linear-gradient(to bottom,#005F96 10%,#004085 10%);
        background: linear-gradient(to top,#0069A6 10%,#0078C0 10%);
    }
    
     background: linear-gradient(#0069A6,#0078C0,#005F96,#004085);
    
    <style>
    .button_color:hover{
        background: linear-gradient(#01152D 10%,#0078C0 100%);
    }
    .button_color:active{
        background: linear-gradient(#0000ff 10%,#ffffff 100%);
    }
    .button_color{
        height:40px;
        border-radius:10px;
        color:white;
        background: linear-gradient(#ff002D 10%,#00eeC0 100%);
    }
    </style>
    
    <button type="button" class="button_color">
    Make Payment
    </button>
    
    .button_color{
    height:40px;
    border-radius:10px;
    color:white;
    background: #0069a6;
    background: -moz-linear-gradient(top, #0069a6 0%, #1e5799 50%, #0078c0 50%, #0078c0 51%, #005f96 100%);
    background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#0069a6), color-stop(50%,#1e5799), color-stop(50%,#0078c0), color-stop(51%,#0078c0), color-stop(100%,#005f96));
    background: -webkit-linear-gradient(top, #0069a6 0%,#1e5799 50%,#0078c0 50%,#0078c0 51%,#005f96 100%);
    background: -o-linear-gradient(top, #0069a6 0%,#1e5799 50%,#0078c0 50%,#0078c0 51%,#005f96 100%);
    background: -ms-linear-gradient(top, #0069a6 0%,#1e5799 50%,#0078c0 50%,#0078c0 51%,#005f96 100%);
    background: linear-gradient(to bottom, #0069a6 0%,#1e5799 50%,#0078c0 50%,#0078c0 51%,#005f96 100%);
    filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#0069a6', endColorstr='#005f96',GradientType=0 );
    }
    .button_color:hover{
    background: #02356a;
    background: -moz-linear-gradient(top, #02356a 0%, #1e5799 50%, #0078c0 50%, #0078c0 50%, #01152d 51%, #002147 100%);
    background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#02356a), color-stop(50%,#1e5799), color-stop(50%,#0078c0), color-stop(50%,#0078c0), color-stop(51%,#01152d), color-stop(100%,#002147));
    background: -webkit-linear-gradient(top, #02356a 0%,#1e5799 50%,#0078c0 50%,#0078c0 50%,#01152d 51%,#002147 100%);
    background: -o-linear-gradient(top, #02356a 0%,#1e5799 50%,#0078c0 50%,#0078c0 50%,#01152d 51%,#002147 100%);
    background: -ms-linear-gradient(top, #02356a 0%,#1e5799 50%,#0078c0 50%,#0078c0 50%,#01152d 51%,#002147 100%);
    background: linear-gradient(to bottom, #02356a 0%,#1e5799 50%,#0078c0 50%,#0078c0 50%,#01152d 51%,#002147 100%);
    filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#02356a', endColorstr='#002147',GradientType=0 );
    }
    .button_color:active{
    background: #004085;
    background: -moz-linear-gradient(top, #004085 0%, #005f96 50%, #0078c0 50%, #0078c0 50%, #0069a6 51%, #0078c0 100%);
    background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#004085), color-stop(50%,#005f96), color-stop(50%,#0078c0), color-stop(50%,#0078c0), color-stop(51%,#0069a6), color-stop(100%,#0078c0));
    background: -webkit-linear-gradient(top, #004085 0%,#005f96 50%,#0078c0 50%,#0078c0 50%,#0069a6 51%,#0078c0 100%);
    background: -o-linear-gradient(top, #004085 0%,#005f96 50%,#0078c0 50%,#0078c0 50%,#0069a6 51%,#0078c0 100%);
    background: -ms-linear-gradient(top, #004085 0%,#005f96 50%,#0078c0 50%,#0078c0 50%,#0069a6 51%,#0078c0 100%);
    background: linear-gradient(to bottom, #004085 0%,#005f96 50%,#0078c0 50%,#0078c0 50%,#0069a6 51%,#0078c0 100%);
    filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#004085', endColorstr='#0078c0',GradientType=0 );
    }