在 rmarkdown 代码块中隐藏滚动条

Hide scrollbar in rmarkdown code blocks

我试图隐藏水平滚动条,当使用 rmarkdowncode_folding 时似乎默认出现水平滚动条(我认为你需要获得 github 的版本) .但是,我似乎无法正确设置 CSS,我认为只需将溢出设置为 'hidden'。

有几个文件,一个是 R 代码,一个是 CSS。示例:

test.R

##' ---
##' title: "Testing Overflow"
##' author: ""
##' date: ""
##' output_format: 
##'   html_document:
##'     theme: readable
##'     highlight: zenburn
##'     code_folding: show
##'     css: styles.css
##' ---
##' 
##' # Some code
##' How can I hide this scroll bar??
##'
##' --------------------------------
##--- test

library(knitr)
opts_chunk$set(message=FALSE, cache=FALSE)

##'

我在

中尝试过的事情

styles.css

.sourceCode {
    overflow: hidden;
}

pre {
    overflow: hidden;
}

从 R 控制台,您应该能够 运行

browseURL(rmarkdown::render("test.R"))

并查看以下内容

编辑: 没有 R.

的请求 jsfiddle

此 CSS 行覆盖了您的规则:

div.sourceCode { overflow-x: auto; }

要么去掉它,要么为你的下一条规则使用相同的特异性,例如:

div.sourceCode {
    overflow: hidden;
}