简体   繁体   中英

How do I change the background color for code block in jekyll?

I'm playing with Jekyll, and have been able to change the background colour for my site. However, no matter which background or background-color properties I change in _syntax-highlighting.scss , I still get the same light grey background (even if I restart the jekyll server).

None of the css/sass default files seem obvious to me for this, either.

_sass/base.scss and change pre, code rule :

pre,
code {
    ...
    background-color: #eef;
}

The answer given by David Jacquel did not work for me.

What worked for me is following;

Go to this file /static/css/main.css and change the parameters for pre .

Background is the background color for the code block, color is the font color in it.

Somehow, .highlight parameters dominate over pre parameters. I commented out as well .highlight section. This is how the final code looks like.

/* Content */
div.content pre {
 background: #d42525;
 padding: 10px;
 color: rgb(20, 199, 29);
 overflow-x: auto;
 font-family: Menlo, Monaco, Consolas, 'Courier New', monospace;
 font-size: 12px;
 border: none;
}
/* Removed this part to be able to change background of "pre" */
/* div.content .highlight { 
 background: #333333;
} */

You can see how the code block looks like with those parameters from here

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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