简体   繁体   English

如何在R闪亮中对齐tabsetpanel“药丸”中心

[英]how to align tabsetpanel "pills" center in R shiny

I am trying to center-align tabsetpanel "pills" on shiny, but it alwais get on left position.我正在尝试将 tabsetpanel “药丸”放在闪亮的中心对齐,但它总是在左侧位置。 Here is the code example, anyone knows how to align this buttons or pills center?这是代码示例,有人知道如何对齐此按钮或药丸中心吗?

library(shiny)
ui <- fluidPage(
  tabPanel(title = "Hello world", value = "HB", 
           tabsetPanel(id="subtabs", type="pills", 
                       tabPanel(title = "TAB 1", value = "ILPF", 
                                br(),
                                h4("I like Pink floyd, my favourite album is 'The dark side of the moon'", style = "color:grey", align = "center"),
                                br()
                       ),
                       tabPanel(title = "TAB 2", value = "FS",  
                                br(),
                                h4("But my favourite song is 'Shine on you crazy diamond'", style = "color:grey", align = "center"),
                                br()
                                )
                       )
           )
)

server <- function(input, output, session) {}
shinyApp(ui = ui, server = server)

The pills should be in the middle of the page药丸应该在页面中间

You can do so by adding some CSS to your app.您可以通过向您的应用添加一些 CSS 来实现。 tags$style('ul.nav-pills{display: flex !important;justify-content: center !important;}') does the trick. tags$style('ul.nav-pills{display: flex !important;justify-content: center !important;}')可以解决问题。

library(shiny)
ui <- fluidPage(
  tags$head(
    tags$style('
    ul.nav-pills{
      display: flex !important;
      justify-content: center !important;
    }')
  ),
  tabPanel(title = "Hello world", value = "HB", 
           tabsetPanel(id="subtabs", type="pills", 
                       tabPanel(title = "TAB 1", value = "ILPF", 
                                br(),
                                h4("I like Pink floyd, my favourite album is 'The dark side of the moon'", style = "color:grey", align = "center"),
                                br()
                       ),
                       tabPanel(title = "TAB 2", value = "FS",  
                                br(),
                                h4("But my favourite song is 'Shine on you crazy diamond'", style = "color:grey", align = "center"),
                                br()
                       )
           )
  )
)

server <- function(input, output, session) {}
shinyApp(ui = ui, server = server)

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM