2013-04-18 235 views
0

我有一个容器,它通过分配一个类名来从全局css文件继承一些设置。但是,当我尝试使用另一个类来更具体地设置背景时,没有任何更改。覆盖CSS背景属性

我的HTML的有趣的部分:

<html> 
     <head> 
      <link rel="stylesheet" type="text/css" href="/styles/global.css"> 
      <link rel="stylesheet" type="text/css" href="/styles/register.css"> 
     </head> 
     <body class="class1 class2"> 
      <div> 
       some content 
      </div> 
     </body> 
    </html> 

而CSS全球

.class1 { 
     /*Shadowing for 3D effect*/ 
     -moz-box-shadow:inset 0px 1px 2px 0px #caefab; /*pale green*/ 
     -webkit-box-shadow:inset 0px 1px 2px 0px #caefab; /*inner/outer, hz-offset, vert-offset, blur-rad, spread, color*/ 
     box-shadow:inset 0px 1px 2px 0px #caefab; 
     /*Background gradient effect*/ 
     background:-webkit-gradient(linear, left top, left bottom, color-stop(0.05, #46bf46), color-stop(1, #1d911d)); /*dark green to light green*/ 
     background:-moz-linear-gradient(center top, #46bf46 5%, #1d911d 100%); 
     filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#46bf46', endColorstr='#1d911d'); 
     /*Rounded corners*/ 
     -moz-border-radius:10px; 
     -webkit-border-radius:10px; 
     border-radius:10px; 
     /*Border*/ 
     border:1px solid #46bf46; 
     /*text settings*/ 
     color: white; /*like chalk*/ 
     text-decoration:none; /*this is default*/ 
     text-shadow:1px 1px 0px #777; /*hzoff vtoff blur color*//*gray makes letters pop out*/ 
     font-family:Verdana, sans-serif; 
     font-size:20px; 
     font-weight:bold; 
    } 

最后的CSS寄存器

.class2 { 
     color: black; 
     background-color: lightgray; 
    } 

的文本颜色是完美,但我重写无法获得改变的背景。

回答

2

CSS上不存在文本颜色。这是颜色

关于背景,请尝试使用背景属性alltogether,而不仅仅是背景颜色。也许浏览器渐变覆盖它。

+0

你是对的。该点在'背景'。 – ncm

+0

谢谢!我总是在代码中弄乱文本颜色/颜色。我太新来CSS了。 – Jaws212