我可以去掉 Flexdashboards 中的顶部栏吗?

Can I get rid of the top bar in Flexdashboards?

我有一个 flex 仪表板,我想去掉顶部栏。

我尝试通过将高度设置为 0px 来使用 CSS 来做到这一点,但我没有成功。

这是我的代码(因为它是 flex 仪表板,所以会很长)


    ---
    title: "Flex"
    author: "I"
    output: 
      flexdashboard::flex_dashboard:
        orientation: rows
    ---
    
    <style>                     
    .navbar {
      background-color:white;
      border-color:white;
    }
    
    .navbar-brand {
      color:white!important;
    }
    
    .navbar-brand {
      color:white!important;
    }
    
    a {
      background-color:white!important;
    }
    
    li {
      background-color:white!important;
    }
    
    body {
      background-color:white;
      border-color:white;
    }
    
    .chart-title {
      background-color:white;
      color:white;
      border-color:white;
    }
    
    #section-chart1 {
      background-color:white;
      border-color:white;
    }
    
    </style>  
    
    ```{r setup, include=FALSE}
    library(ggplot2)
    library(plotly)
    library(plyr)
    library(flexdashboard)
    library(hrbrthemes)
    
    # Make some noisily increasing data
    set.seed(955)
    dat <- data.frame(cond = rep(c("A", "B"), each=10),
                      xvar = 1:20 + rnorm(20,sd=3),
                      yvar = 1:20 + rnorm(20,sd=3))
    
    ```{}

    Page One
    =======================================================================
    
    Row
    -----------------------------------------------------------------------
    
    ### chart1
    
    
    ```{r}
    p <-
      iris %>% 
        ggplot(aes(Sepal.Length, Sepal.Width)) +
                  geom_point(size = 2, color = "purple") +
                  theme_ipsum_rc(grid = "XY") +
                  labs(title = "Sepal Length by sepal width")
    
    ggplotly(p)

您可以忽略第一个代码块末尾的 {}。我把它加在那里,这样堆栈溢出就会把整个东西作为一个代码块。

我已经使用 CSS 成功地使其不可见,现在我想完全摆脱它。

如果您将 .navbar 设置为 display: none,导航栏将不会显示,将 body 设置为 padding-top: 0; 将帮助您摆脱间距。

.navbar {
  display:none;
}

body {
  padding-top: 0;
}