简体   繁体   English

水平对齐一个 selectizeInput 和两个 actionButton

[英]Align a selectizeInput and two actionButtons horizontally

This is a snippet of my interface (if choices = c() it means that the choice is managed on the server side):这是我的界面的一个片段(如果choices = c()这意味着选择是在服务器端管理的):

sidebarPanel(
    selectizeInput(
        "s1",
        "Select s1",
        choices = c(),
        multiple = FALSE
    ),
    div(style = "margin-top:-15px"),
    radioButtons(
        "r1",
        "Select r1",
        choices = c("A", "B", "C")
    ),
    div(style = "margin-top:-15px"),
    selectizeInput(
        "s2",
        "Select s2",
        choices = c(),
        multiple = FALSE
    ),
    div(style = "margin-top:-15px"),
    selectizeInput(
        "s3",
        "Select s3",
        choices = c(),
        multiple = TRUE
    ),
    div(style = "margin-top:-15px"),
    actionButton(
        "b1",
        "Enter"
    ),
    actionButton(
        "b2",
        "Enter"
    ),
    div(style = "margin-top:-15px"),
    selectizeInput(
        "s4",
        "Select s4",
        choices = c(),
        multiple = FALSE
    )
)

My question is: How can I arrange the selectizeInput s3 and the actionButtons b1 and b2 all on the same line horizontally?我的问题是:如何将 selectizeInput s3和 actionButtons b1b2水平排列在同一行?

You can add columns in a fluid row:您可以在流动行中添加列:

library(shiny)

ui <- fluidPage(
  sidebarPanel(
    fluidRow(
      column(
        width = 4,
        selectizeInput(
        "s3",
        "Select s3",
        choices = c(),
        multiple = TRUE,
      )),
      div(style = "margin-top:45px"),
      column(
        width = 4,
        actionButton("b1","Enter")
      ),
      div(style = "margin-top:45px"),
      column(
        width = 4,
        actionButton("b2","Enter")
      )
    )
  )
)


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

}

shinyApp(ui, server)

在此处输入图像描述

The action buttons do not have a title so they need to be pushed downwards eg using margin-top to align the buttons with the text input box.操作按钮没有标题,因此它们需要向下推动,例如使用margin-top将按钮与文本输入框对齐。

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

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