【问题标题】:Adjust the height of infoBox in shiny dashboard调整闪亮仪表板中信息框的高度
【发布时间】:2016-06-16 13:50:03
【问题描述】:

我有一个像这样的非常基本的信息框,并且想要调整高度,因为当前高度对于我要合并的东西来说太过分了。

知道我该怎么做吗?我尝试了这里的建议:r shinydashboard - change height of valueBox。但是,这并没有任何改变。

sidebar <- dashboardSidebar(
  sidebarMenu(id = 'sidebarmenu',
              menuItem('About', tabName = 'about'))
  )

about <- tabItem('about', fluidPage(
  fluidRow(
      infoBoxOutput('age')
    )
  )
)

body <- dashboardBody(
  tabItems(
   about 
  )  
)

ui <- dashboardPage(
  dashboardHeader(
    title = 'My App'
  ),
  sidebar = sidebar,
  body = body
)

server <- function(input, output) {
  output$age <- renderInfoBox({
    infoBox('Age: ', 50, icon = icon('list'), width = 6)
  })
}

shinyApp(ui = ui, server = server)

【问题讨论】:

    标签: r shiny shinydashboard


    【解决方案1】:

    您需要应用一些 CSS 规则。

    body <- dashboardBody(
        tags$head(tags$style(HTML('.info-box {min-height: 45px;} .info-box-icon {height: 45px; line-height: 45px;} .info-box-content {padding-top: 0px; padding-bottom: 0px;}'))),
        tabItems(
            about 
        )  
    )
    

    【讨论】:

    • 像魅力一样工作。只是希望我不必处理这种类型的代码,而是为infoBox 提供一个名为height 的参数。 :)
    • 有一些 Shiny UI 元素支持heightstyle="height:500px;"。但在这种情况下,高度实际上是由几个元素(信息框和图标)决定的。
    • @Xiongbing Jin,感谢您的 tags$head 命令,它也帮助我解决了我的要求,请帮我解决这个需要稍微调整的链接。 stackoverflow.com/questions/47154749/…
    猜你喜欢
    • 1970-01-01
    • 2018-05-30
    • 2017-05-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-04-22
    • 2020-07-17
    相关资源
    最近更新 更多