简体   繁体   English

修改Wordpress插件的CSS?

[英]Amend CSS of Wordpress Plugin?

I'm using WordPress, a Forum plugin and a Syntax Highlighter plugin. 我正在使用WordPress,一个论坛插件和一个Syntax Highlighter插件。

At the moment the Syntax Highlighter styles render fine in a 'native' WordPress post/page. 目前,语法荧光笔样式在“原生”WordPress帖子/页面中呈现正常。 However they don't render correctly on the Forum plugin pages. 但是它们无法在论坛插件页面上正确呈现。 This is due to the Forum CSS overriding some of the Syntax Highlighter CSS. 这是因为Forum CSS覆盖了一些Syntax Highlighter CSS。

Consider this 'simplified' example: https://jsfiddle.net/2vkzx1js/ 考虑这个“简化”的例子: https//jsfiddle.net/2vkzx1js/

<div id="forum">
  <div class="post">
      <div class="syntaxhighlighter">
          <span>This should be red</span>
      </div>
  </div>
  <div class="post">
      <div>
          <span>This should be blue</span>
      </div>      
  </div>
  <div class="post">
      <div>
          <span>This should be blue</span>
      </div>
  </div>
</div>

and

#forum .post span
{
    color:blue;
}

.syntaxhighlighter span {
  color:red;
}

I know that if I add '#forum' to the start of the CSS declarations in the Syntax Highlighter plugin it would render ok: 我知道如果我在语法Highlighter插件的CSS声明的开头添加'#forum',它将呈现正常:

#forum .syntaxhighlighter span {
  color:red;
}

But I don't want to start overwriting plugin files for obvious reasons. 但出于显而易见的原因,我不想开始覆盖插件文件。

What are the most feasible options to fix this? 解决这个问题最可行的选择是什么?

You don't need to make modifications to the plugin css files, you can just make those modifications in your own custom css file. 您不需要对插件css文件进行修改,只需在自己的自定义css文件中进行修改即可。 The problem, as you've already discovered, is the selector process. 正如您已经发现的那样,问题在于选择器进程。 You can just remove #forum from the first line and it works just fine: https://jsfiddle.net/vuc6ybt4/ 您可以从第一行删除#forum ,它可以正常工作: https#forum

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

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