【问题标题】:Place tab in Shiny tabsetPanel on the right将选项卡放在右侧的 Shiny tabsetPanel 中
【发布时间】:2018-06-21 17:34:58
【问题描述】:

tabsetPanel 中的默认选项卡位于左侧。是否可以在右侧放置一个选项卡,而左侧仍然有其他选项卡?所以它看起来像这样?

library(shiny)

ui <- fluidPage(
  tabsetPanel(
    tabPanel("tab_left1"),
    tabPanel("tab_left2"),
    tabPanel("tab_right")
  )
)

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

shinyApp(ui, server)

【问题讨论】:

    标签: css r shiny bootstrap-4


    【解决方案1】:

    使用float-right 确实应该有效。使用 2 tabsetPanel 的问题是同时有 2 个活动标签。

    library(shiny)
    
    ui <- fluidPage(
      tags$head(
        tags$style(HTML(
          ".tabbable ul li:nth-child(3) { float: right; }"
        ))
      ),
      tabsetPanel(
        tabPanel("tab_left1"),
        tabPanel("tab_left2"),
        tabPanel("tab_right")
      )
    )
    
    server <- function(input, output, session) {}
    
    shinyApp(ui, server)
    

    【讨论】:

      【解决方案2】:

      也许你可以创建 2 个 tabsetPanel 并将一个拉到右边?

      rm(list = ls())
      library(shiny)
      ui <- fluidPage(
        div(style="display:inline-block",tabsetPanel(type = c("pills"),tabPanel("tab_left1"),tabPanel("tab_left2"))),
        div(style="display:inline-block;float: right",tabsetPanel(type = c("pills"),tabPanel("tab_right")))
      )
      
      server <- function(input, output, session) {}
      
      shinyApp(ui, server)
      

      【讨论】:

        【解决方案3】:

        当你将 float-right 类应用到你想向右浮动的那些上时,它应该可以解决问题。

        【讨论】:

        • 感谢您的想法。我在 UI 中添加了tags$style(HTML(" .tabbable &gt; .nav &gt; li &gt; a[data-value='tab_right'] {float:right} ")),但它不起作用。怎么了?
        猜你喜欢
        • 2017-07-21
        • 2014-05-20
        • 2020-05-05
        • 1970-01-01
        • 1970-01-01
        • 2023-03-19
        • 1970-01-01
        • 1970-01-01
        • 2016-06-06
        相关资源
        最近更新 更多