css - 如何更改突出显示 CSS 的语法?

标签 css wordpress-theming syntax-highlighting

我在 WordPress.com 上托管了一个博客,我购买了“自定义 CSS”更新来修改 CSS。现在我想更改 Syntax Highlighting 的一些 CSS 选项由 Wordpress.com 提供。例如,我想要那个

   [code lang="C"] int main() { } [/code] 

将以黑色背景显示,而不是标准的白色背景。我在 Wordpress.com Appareance > Modify CSS 中添加了以下代码:

 .syntaxhighlighter
 {
    background-color: black !important;
 }

如解释here ,但它不起作用。 有什么想法吗?

最佳答案

解决方法是不仅要改变整个syntaxhighlighter的背景,还要改变每一行的背景,类似这样:

.syntaxhighlighter
{
    background-color: black !important;
}
.syntaxhighlighter .line .number
{
    color: white !important;
    background-color: black !important;
}
/* First line */
.syntaxhighlighter .line.alt1
{
    background-color: black !important;
}

/* Second line */
.syntaxhighlighter .line.alt2
{
    background-color: black !important;
}

当您使用黑色作为背景色时,我建议您确保颜色与其相比具有足够的对比度。

此外,使用 firebug plugin for firefox您可以准确地看到哪些 CSS 规则在何处应用,以及哪些类可用于样式设置。 (在托管系统上工作时必须的。)

顺便说一句:我在 second link 找到了解决方案你给了

关于css - 如何更改突出显示 CSS 的语法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3061941/

相关文章:

javascript - 如何根据行展开和折叠行

css - 使用 Font Awesome 图标的可见焦点

css - 为什么我的链接无法使用 Css 转换和 Z-index?

c++ - 关闭 C++ 注释中的 vim 语法高亮

ruby - 为什么语法突出显示不适用于 Chrome Devtools 中的 Ruby 文件 (.erb)?

linux - 科奇德 8.5 : No syntax highlighting on Linux

javascript - 如何将相对元素定位在与其父元素在文档中相同的坐标中?

wordpress - 如何在wordpress中使用wp_mail()函数

javascript - 如何在子主题中覆盖联系表单7 js文件

php - 向 Wordpress 主题添加子菜单