【问题标题】:Rmarkdown, pin author name to bottom of sidebarRmarkdown,将作者姓名固定到侧边栏底部
【发布时间】:2021-01-07 06:03:27
【问题描述】:

我正在使用 rmarkdown 编写一个 html 文档。我想将作者(可能还有日期)固定在左下角(在侧边栏中)。
我有点知道我需要以某种方式让这种风格发挥作用

 .sidebar-footer{
height: 50px;
position: absolute;
width: 100%;
bottom: 0;
list-style-type: none;
padding-bottom:5.5em;
}

我的 rmd 文件是:

---
title: "project"
author: "Name"
date: "11/12/2020"
output:
  html_document:
    toc: true
    toc_float: true
    toc_collapsed: true
    toc_depth: 3
    theme: lumen
    highlight: default
    css: www/css/master.css
---
```{css}
tocify.sidebar-footer{
height: 50px;
position: absolute;
width: 100%;
bottom: 0;
list-style-type: none;
padding-bottom:5.5em;
}
```


<div style="sidebar-footer"> hello 
</div>

# Level one

```{r}
plot(1:10,2:11)
```

## level two

### level three

# level one a

我的自定义 CSS 是

#TOC{   
    margin: 0 !important;
    height: 100%;
    border: none;
    padding: 0;
    background-color: #f8f8f8;
    left: 0;
    border-right: 1px solid #e7e7e7}
      
.tocify{
  background-color: #f8f8f8;
  border-radius: 0px;
}

.list-group-item{
  background-color: #f8f8f8;
}

div.tocify {
    width: 20%;
    max-width: 260px;
    max-height: 100% !important;
}

我对 html 和 css 的工作原理并不太熟悉,因此我将不胜感激。 R具有生成浮动目录等的默认css

【问题讨论】:

    标签: html css r markdown


    【解决方案1】:

    猜猜如果你使用闪亮和闪亮的仪表板会更容易。

    这是一个完整的例子。

    首先,您需要准备一个新的闪亮网络应用程序。从 RStudio > 文件 > 新文件 > Shiny Web App(下面的 1 个),然后选择单个文件应用程序(下面的 2 个)。

    最后复制/粘贴以下代码。

    ## app.R ##
    library(shiny)
    library(shinydashboard)
    
    author <- "John Doe"
    
    ui <- dashboardPage(
        dashboardHeader(title = "TestApp"),
        dashboardSidebar(HTML(paste0(
            "<div style='position: absolute; bottom: 5px;'>",
            author,"<br>",Sys.Date(),
            "</div>"
            ))
            ),
        dashboardBody("Hello")
    )
    
    server <- function(input, output) { }
    
    shinyApp(ui, server)
    

    【讨论】:

    • 感谢您的想法,不幸的是,该文档的目标是不需要服务器。因此,Shiny 似乎是不可能的,除非你可以嵌入输出?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-01-25
    • 1970-01-01
    • 1970-01-01
    • 2015-02-04
    • 1970-01-01
    • 2012-04-27
    • 1970-01-01
    相关资源
    最近更新 更多