简体   繁体   English

如何覆盖CSS或为node_module换皮肤?

[英]How to override CSS or re-skin for node_module?

I have a node_module https://github.com/Alberplz/angular2-color-picker that I am using in my angular 2 project, but as all modules it includes it's CSS files and if I do inspect element i see in listed as localhost, but can't actually locate where they are. 我在我的angular 2项目中使用了一个node_module https://github.com/Alberplz/angular2-color-picker ,但是作为所有模块,它都包含CSS文件,如果我检查元素,我会在localhost中列出,但实际上无法找到它们的位置。

I could create a separate file and overwrite but than I making a bigger mess as putting CSS on top of CSS and I would like to re skin the module. 我可以创建一个单独的文件并覆盖它,但是比将CSS放在CSS顶部时要大得多,我想重新设计模块外观。

This is how the CSS looks now 这就是CSS的外观 在此处输入图片说明

Any suggestion? 有什么建议吗?

If you look into the repository of that project you can locate style here . 如果您查看该项目的资源库,则可以在此处找到样式。 The compiled style is imported to directive here . 编译后的样式在此处导入到指令中。 I don't see any example of changing color picker style other than this options . 除了此选项外,我没有看到任何改变颜色选择器风格的例子。

If you want to override the style you might have to use some "shadow DOM breaking" solution or global style that will override it with more specific selector, eventually an !important keyword. 如果要覆盖样式,则可能必须使用一些“影子DOM破坏”解决方案或全局样式,这些解决方案或全局样式将使用更特定的选择器(最终是!important关键字)来覆盖它。

This component is extended in the ngx set of components ( https://www.npmjs.com/package/ngx-color-picker ngx-color-picker ) and I have been able to set styling by overriding style in a tag in the Index.html in Angular 5 application. 该组件在ngx组件集中进行了扩展( https://www.npmjs.com/package/ngx-color-picker ngx-color-picker ),我已经能够通过覆盖样式中的标记来设置样式Angular 5应用程序中的Index.html。 The style tag must be below the body tag 样式标签必须在正文标签下方

Basically the steps I understand to overwrite a module is to: 基本上,我了解的覆盖模块的步骤是:

  1. Fork the github environment locally 在本地分叉github环境
  2. Git clone your forked enviorment Git克隆您的分叉环境
  3. Register on npm 在npm注册
  4. Apply changes to your local and publish on npm under different name 将更改应用到本地,然后以不同的名称发布到npm
  5. Npm install the published npm pacakage. Npm安装已发布的npm pacakage。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM