2013-08-01 37 views

回答

1

最简单的解决方案是覆盖CSS规则的评论,但它们被标记为!important,所以你必须做一些额外的工作。

打开您的shBrushCpp.js文件。倒向底部,有一组正则表达式规则与css属性配对。这些值对应于shThemeDefault.css中的类名称(或您正在使用的任何主题)。

将您的主题文件复制到像shThemeCustom.css或任何你想要的东西。将此文件包含在您的页面上而不是原始主题中。从这里,你可以改变任何你想要的。只需根据自定义主题引用画笔文件中的CSS规则即可知道需要更改哪些内容。

+0

我有一个问题。我无法访问我所知道的任何自定义css文件,因为[在此处按照此安装](http://beendaved.blogspot.com/2015/03/working-with-syntax-highlighter-in.html ),并使用Alex Gorbatchev的在线主机(例如:http://alexgorbatchev.com/pub/sh/current/styles/shThemeDefault.css,http://alexgorbatchev.com/pub/sh/current/scripts/shBrushCpp。 js等,按照上面的说明),那么我怎么能在我的情况下做到这一点?注意:[我的网站](http://www.electricrcaircraftguy.com/)是一个Google Blogger博客。 –

+0

我刚刚加了[我的答案在这里](http://stackoverflow.com/a/40179189/4561887)。花了我几个小时,但我明白了一切。 –

0

如果你没有过的CSS或.js文件完全控制,这是我的情况下(因为我也跟着these instructions here和正在使用Alex Gorbatchev's hosted files instead),还有a way to override the !important parameter

您可以自定义任何这里所示的设置(http://agorbatchev.typepad.com/pub/sh/3_0_83/styles/shThemeDefault.css),例如,如下:

使用默认主题,HTML ...

<pre class="brush:cpp" title="test code"> 
int myFunc() 
{ 
    //do something 
    return 1; 
} 
</pre> 

...收益率这一结果:

enter image description here

看这里(http://agorbatchev.typepad.com/pub/sh/3_0_83/styles/shThemeDefault.css),我可以看到我目前使用的参数。例如,它包含:

.syntaxhighlighter { 
    background-color: white !important; 
} 
.syntaxhighlighter .line.alt1 { 
    background-color: white !important; 
} 
.syntaxhighlighter .line.alt2 { 
    background-color: white !important; 
} 
... 
.syntaxhighlighter .comments, .syntaxhighlighter .comments a { 
    color: #008200 !important; 
} 

为了从顶部到底部,如图所示的正上方,我的标题背景颜色是白色和我的交替代码行1和2均为白色。评论是绿色的(#008200)。让我们改变这一切。下面的代码添加到您的博客模板,在你的头的最后,略高于</head>

<style type='text/css'> 
    .syntaxhighlighter { 
    max-height: 550px; 
    background-color: #ff0000 !important; 
    overflow-y: auto !important; 
    overflow-x: auto !important; 
    } 
    .syntaxhighlighter .line.alt1 { 
    background-color: #99ff99 !important; 
    } 
    .syntaxhighlighter .line.alt2 { 
    background-color: #99ff99 !important; 
    } 
    .syntaxhighlighter .comments, .syntaxhighlighter .comments a { 
    color: #000082 !important; 
    font-weight: bold !important; 
    } 
</style> 

现在,我已经把我的max-height 550像素(做一个很长的代码块,你会看到它现在约束到这个高度,用一个垂直滑动条来看这一切),我的标题背景颜色是红色的(#ff0000),我的代码背景色(交替线)是浅绿色(#99ff99),我的评论是蓝色的(#000082 )和黑体。按照这种格式来定制您在.css主题文件中看到的任何内容 - 例如,对我来说,在这里:http://agorbatchev.typepad.com/pub/sh/3_0_83/styles/shThemeDefault.css

这是我最后的结果 - 从上面的默认外观截然不同:

enter image description here

注意,font-weight参数我设置很简单,你可以应用CSS样式。存在许多其他选项。看到这里:http://www.w3schools.com/cssref/pr_font_weight.asp

〜加布里埃尔斯台普斯
www.ElectricRCAircraftGuy.com

相关问题