【问题标题】:R knitr markown: Setting HTML page widthR knitr markown:设置 HTML 页面宽度
【发布时间】:2015-02-12 14:55:17
【问题描述】:

我正在使用knitr 创建一个 HTML 网页。默认设置似乎是 800 像素,但我需要更大的页面大小 1100 像素

body {
    max-width: 800px;
    margin: auto;
    padding: 1em;
    line-height: 20px ; 
}   

我试过了:

library("markdown")
library("knitr")
knit2html("test.Rmd",options = c(width=1100))

但这仍然给了我 800 像素的较小页面尺寸

如何设置 HTML 页面宽度的代码?

【问题讨论】:

    标签: css r knitr


    【解决方案1】:

    在您的文档中添加css 元素,例如

    ---
    title: "test"
    
    output:
      html_document:
        css: "test.css"
    ---
    

    然后将新的 css 信息放入该文件中,例如

    body {
      max-width: 1100px;
      margin: auto;
     padding: 1em;
     line-height: 20px ; 
    }   
    

    【讨论】:

    • 谢谢。由于某种原因,这对我不起作用,但后来我尝试了: 效果很好。
    • 这仅在我将!important 规则添加到max-width 定义中时才有效,正如this answer 中所建议的那样。使用该规则seems bad practice,那么还有其他方法吗?
    • 这对我也不起作用(没有改变)。 @adam.888 您能否分享您在何处/如何添加“”以使其工作?谢谢!
    猜你喜欢
    • 1970-01-01
    • 2013-12-04
    • 2014-06-16
    • 1970-01-01
    • 2011-08-16
    • 1970-01-01
    • 1970-01-01
    • 2019-08-12
    • 1970-01-01
    相关资源
    最近更新 更多