【发布时间】:2018-03-17 00:56:49
【问题描述】:
我刚刚开始使用 R-Shiny。但是我在 Shiny 中使用 js 和 html 代码时遇到了一些麻烦。
在我的应用程序中,我有两个bsButton,当悬停时会显示一些带有bsPopover 的文本。其中一个弹出框包含一个大于弹出框标准框的图像,我想设置此弹出框的宽度以完全包含该图。
Here我找到了如何设置所有弹出框的宽度和高度,但是如何设置仅特定弹出框的宽度/高度?
这是我目前的代码,我想更改 bsPopover(id="q2", ...) 的宽度,但不更改 bsPopover(id="q1", ...) 的宽度:
library(shiny)
library(shinyBS)
ui <- fluidPage(
tags$head(
# this changes the size of the popovers
tags$style(".popover{width:200px;height:250px;}")
),
fluidRow(
fileInput("file", label=h4("Upload Data",
tags$style(type = "text/css", "#q1 {vertical-align: top;}"),
bsButton("q1", label="", icon=icon("question"), style="info", size="extra-small")),
accept=".txt"
),
bsPopover(id="q1", title="Title help text1",
content=paste("help text"),
placement = "right",
trigger = "hover",
options = list(container = "body")
),
numericInput("numIn", label = h4("Choose a value",
tags$style(type="text/css", "#q2 {vertical-align: top;}"),
bsButton("q2", label="", icon=icon("question"), style="info", size="extra-small")),
value = 2.5, step=0.5),
bsPopover(id="q2", title="Title help text 2",
content=paste0("The figure below shows",
img(src='scenarios.png', align = "center", height="320px", width="800px", style="display:block;margin-top:20px;margin-left:auto;margin-right:auto;")
),
placement = "right",
trigger = "hover",
options = list(container = "body")
)
)
)
server <- function(input, output) {}
shinyApp(ui = ui, server = server)
【问题讨论】: