1

我有一个 bs4card,我想并排添加 2 个选择输入。正如您从所附照片中看到的那样,即使列宽设置为 6,选择输入也会被挤压。

下面是我的代码...

bs4Card(
      width =6,
      title = "Position Re-Balancer",
      collapsible = F,
      closable = F,
      maximizable = T,
      elevation = 2,
 
  #block of code which we are looking at
  fluidRow(
  column(width = 6,
  selectizeInput("bullpos", "Bull", choices = l.etfs$Bull)
  ),
  column(width = 6,
  numericInput("positionbull", "Bull Shares", value = -100)
  )
  ),
  
  selectizeInput("bearpos", "Bear", choices = l.etfs$Bear),
  numericInput("positionbear", "Bear Shares", value = -100),
  numericInput("moneyallocated", "Max $ Allocation", value = 5000)
  
  
) 

在此处输入图像描述

4

1 回答 1

3

这是bs4Card帮助页面中的改编示例。我使用了你的卡,但将卡的值设置width为 12。

library(shiny)
library(bs4Dash)

shiny::shinyApp(
  ui = bs4DashPage(
    navbar = bs4DashNavbar(),
    sidebar = bs4DashSidebar(),
    controlbar = bs4DashControlbar(),
    footer = bs4DashFooter(),
    title = "test",
    body = bs4DashBody(
      fluidRow(
        column(
          width = 6,
          bs4Card(
            title = "Closable Box with dropdown", 
            closable = TRUE, 
            width = 12,
            status = "warning", 
            solidHeader = FALSE, 
            collapsible = TRUE,
            cardLabel = bs4CardLabel(
              text = 1,
              status = "danger",
              tooltip = "Hello!"
            ),
            dropdownMenu = dropdownItemList(
              dropdownItem(url = "http://www.google.com", name = "Link to google"),
              dropdownItem(url = "#", name = "item 2"),
              dropdownDivider(),
              dropdownItem(url = "#", name = "item 3")
            ),
            p("Box Content")
          )
        ),
        column(
          width = 6, 
          bs4Card(
            width =12,
            title = "Position Re-Balancer",
            collapsible = F,
            closable = F,
            maximizable = T,
            elevation = 2,
            
            #block of code which we are looking at
            fluidRow(
              column(width = 6,
                     selectizeInput("bullpos", "Bull", choices = c("A", "B"))
              ),
              column(width = 6,
                     numericInput("positionbull", "Bull Shares", value = -100)
              )
            ),
            
            selectizeInput("bearpos", "Bear", choices = c("A", "B")),
            numericInput("positionbear", "Bear Shares", value = -100),
            numericInput("moneyallocated", "Max $ Allocation", value = 5000)
            
            
          ) 
        )
      )
    )
  ),
  server = function(input, output) {
    output$distPlot <- renderPlot({
      hist(rnorm(input$obs))
    })
  }
)

这里看起来不错。为了更好地理解代码中的问题所在,请提供一个最小的可重现示例,即具有您使用的 UI 的正在运行的应用程序。

在此处输入图像描述

于 2020-08-24T19:48:14.620 回答