【问题标题】:Removing White Space between Shiny Dashboard Header and Leaflet Map删除闪亮的仪表板标题和传单地图之间的空白
【发布时间】:2019-04-01 15:08:50
【问题描述】:

我有一个显示传单地图的 Shiny 应用程序。我正在尝试删除 Shiny 仪表板标题和地图之间的空白。我还想删除侧边距上的空白。我怀疑这样做需要通过 CSS 修改边距或填充,但我还没有找到解决方案。

这是我的应用的简化版本的代码 -

```{r}
ui <- navbarPage("Example Page", id = "nav",
       tabPanel("Some Header",
                tags$style(type = "text/css", "#map {height: 
                calc(100vh - 70px) !important;}"), 
                  leafletOutput("map")))

server <- function(input, output, session) {
             output$map <- renderLeaflet({
            leaflet() %>%
            addTiles() %>% 
            setView(lng = -93.85, lat = 37.45, zoom = 5)})
}

shinyApp(ui, server)

```

这是生成的应用的图片。我想知道如何修改此代码以删除所有空格。

Example_App

【问题讨论】:

  • 我会在 Chrome 中查看应用程序,然后右键单击有问题的间隙并单击“检查”。从这里,您将能够调整相关元素的边距大小。如果可行,那么您可以通过将 css 添加到应用程序来调整相关元素的 css。 (有关详细信息,请参阅 rstudio.com 上的 Shiny 帮助页面。)

标签: r leaflet shinydashboard


【解决方案1】:

p0bs,你的评论让我走上了正轨。这是我用来重新格式化这个 Shiny 应用程序的代码,以便没有空格 -

```{r}
ui <- navbarPage("Example Page", id = "nav",
       tabPanel("Some Header",
                tags$style(type = "text/css", "#map {height: calc(100vh - 
53px) !important;}"), 
                  leafletOutput("map")),
         tags$style(type = "text/css", ".container-fluid {padding-left:0px;
                    padding-right:0px;}"),
         tags$style(type = "text/css", ".navbar {margin-bottom: .5px;}"),
        tags$style(type = "text/css", ".container-fluid .navbar-header 
.navbar-brand {margin-left: 0px;}"))

server <- function(input, output, session) {
output$map <- renderLeaflet({
leaflet() %>%
  addTiles() %>% 
  setView(lng = -93.85, lat = 37.45, zoom = 5)})
}

shinyApp(ui, server)
```

这是结果的图像 -

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-05-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-02-24
    • 1970-01-01
    相关资源
    最近更新 更多