gpt4 book ai didi

css - Shiny 的 selectInput 旁边的标签

转载 作者:技术小花猫 更新时间:2023-10-29 11:19:34 29 4
gpt4 key购买 nike

我有这样一个 Shiny 的应用程序:

服务器.R:

    library(shiny)

function(input, output) { NULL }

和 ui.R:

    library(shiny)  


pageWithSidebar(

headerPanel("side-by-side"),

fluidRow(

column(2),
column(4,
wellPanel(
selectInput(inputId = "options", label = "some text",
choices = list(a = 0, b = 1)))
)
),

fluidRow(
h3("bla bla")
)
)

而且我希望 selectInput 的标签在它旁边,而不是在上面。你知道怎么做吗?

我找到了这个:Positioning Shiny widgets beside their headers但它对我不起作用。

最佳答案

有多种方法可以做到这一点,这里是一种:

library(shiny)

server <- shinyServer(function(input, output) { NULL })
ui <- shinyUI(
pageWithSidebar(

headerPanel("side-by-side"),

sidebarPanel(
fluidRow(
tags$head(
tags$style(type="text/css", "label.control-label, .selectize-control.single{ display: table-cell; text-align: center; vertical-align: middle; } .form-group { display: table-row;}")
),
column(2),
column(4,
selectInput(inputId = "options", label = "some text",
choices = list(a = 0, b = 1))
)
)),
mainPanel(
fluidRow(
h3("bla bla")
))
)
)

shinyApp(ui=ui,server=server)

如果您不想弄乱 Shiny 的默认 CSS,您可以将标签留空并在其旁边创建一个标签,而不是将现有标签强制放在一边。

关于css - Shiny 的 selectInput 旁边的标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33960035/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com