chrome plugin css injection

时间:2012-02-03 04:46:01

标签: google-chrome css3 google-chrome-extension google-chrome-devtools

您好我正在尝试将自定义css注入页面,我的清单文件如下所示

{
  "name": "SaneHaveeru",
  "version": "1.0",
  "description": "This is to properly display haveeru .",
  "browser_action": {
    "default_icon": "icon.png"
  },
  "content_scripts": [
    {
      "matches": ["http://www.haveeru.com.mv/*"], 
      "css" : ["proper.css"]
    }
],
  "permissions": [
    "http://www.haveeru.com.mv/"
  ]

}

我注射的css是

.post-frame {
    float: left;
    width: 470px;
    font-size: 18px;
    line-height: 30px;
    color: #292929;
}

但似乎页面css覆盖了我的自定义CSS。如此处所见 screen shot of chrom developer tool showing my css being overridden by the pages css他们是否可以强制我的css更改到页面?

欢呼声 纳什rafeeq

2 个答案:

答案 0 :(得分:1)

使用JavaScript设置样式。它将覆盖任何页面样式。

答案 1 :(得分:1)

!important放在所有css规则的末尾......

.post-frame {
    float: left !important;
    width: 470px !important;
    font-size: 18px !important;
    line-height: 30px !important;
    color: #292929 !important;
}

http://webdesign.about.com/od/css/f/blcssfaqimportn.htm