如何在现有的CSS中添加新属性?

时间:2013-12-23 17:34:54

标签: css

我有两个css文件。我在下面的一个CSS中有一个类

input[type="submit"], input[type="button"], .butLink {
    padding: 3px 9px;
    -moz-border-radius: 3px;
    -webkit-border-radius: 3px;
    -khtml-border-radius: 3px;
    border-radius: 3px;
    -moz-box-shadow: inset 1px 1px 0 rgba(255,255,255,0.3);
    -webkit-box-shadow: inset 1px 1px 0 rgba(255,255,255,0.3);
    box-shadow: inset 1px 1px 0 rgba(255,255,255,0.3);
    font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
    font-size: 12px;
    font-weight: bold;
    cursor: pointer;

    color: #FFFFFF;
    background: #A5BD24;
    background: -moz-linear-gradient(top, #A5BD24 0%, #7DAC38 100%);
    background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#A5BD24), color-stop(100%,#7DAC38));
    background: -webkit-linear-gradient(top, #A5BD24 0%,#7DAC38 100%);
    background: -o-linear-gradient(top, #A5BD24 0%,#7DAC38 100%);
    background: -ms-linear-gradient(top, #A5BD24 0%,#7DAC38 100%);
    filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#a5bd24', endColorstr='#7DAC38',GradientType=0 );
    background: linear-gradient(top, #A5BD24 0%,#7DAC38 100%);
    text-shadow: 0 1px 1px rgba(0, 0, 0, 0.25);
    border: 1px solid #781;
}

现在我想从另一个css文件中更改此样式。我尝试按照下面的方法进行操作 -

input[type="submit"], input[type="button"], .butLink
{
    background-color:#000 !important;
}

任何想法?

3 个答案:

答案 0 :(得分:1)

编写background将覆盖先前定义的属性。

写:

input[type="submit"], input[type="button"], .butLink{
    background:#000;
}

答案 1 :(得分:0)

尝试使用background规则而不是background-color,并确保您的样式表在HTML的<head>中的顺序正确。如果它们的顺序正确,则规则不应该是!important

答案 2 :(得分:0)

You can do it easily.

Option one: If you apply this css rule for the particular page so use internal css .Add this rule within the header tag like this 


          <style>
             input[type="submit"], input[type="button"], .butLink
             {
                  background-color:#000 !important;
             }
          </style>

It will perfectly works because internal css overwrite the external css rule.

Option two: If you apply this css rule for the all pages so use external css .Add this rule after the last css property:value;like this
       color: #FFFFFF;
       background: #A5BD24;  
       background:#000;/* This will overwrite with the previous background property value #A5BD24;
Hope the answer!