英文:
How to change the style of the hover text generated by tags$i?
问题
我正在寻找一种改变由 tags$i
生成的悬停文本(如字体、背景颜色等)布局的方法。样式参数仅适用于生成的图标,而不适用于悬停时出现的标题。我发现使用 shinyBS
有几种选项,但不幸的是,我受限于使用 tags$i
。
这里有一个小例子:
library(shiny)
shinyApp(
ui = fluidPage(
selectInput("Input",
label = tags$span(
"Input",
tags$i(
class = "glyphicon glyphicon-info-sign",
style = "color: black",
title = "hover text"
),
),
choices = c("a","b")),
),
server = function(input, output) {}
)
希望这能帮助你。
英文:
I am looking for a way to change the layout (such as font, background colour, etc.) of the hover text ("title") generated by tags$i
. The style argument applies only to the icon generated, not the title appearing upon hover. I found several options using shinyBS
but, unfortunately, I am restricted to tags$i
.
Here's a small example:
library(shiny)
shinyApp(
ui = fluidPage(
selectInput("Input",
label = tags$span(
"Input",
tags$i(
class = "glyphicon glyphicon-info-sign",
style = "color: black",
title = "hover text"
),
),
choices = c("a","b")),
),
server = function(input, output) {}
)
答案1
得分: 1
这是一种不使用shinyBS
的可能性:将信息标志添加为单独的div
,并分别添加相应的HTML
和CSS
。然后,您可以在悬停在信息标志上时完全自定义显示的文本。
library(shiny)
shinyApp(
ui = fluidPage(
tags$head(tags$style(
HTML(
"
#info-sign {
margin-left:40px;
margin-top:3px;
position: absolute;
}
#info-sign .text {
position:absolute;
bottom:-5px;
left:20px;
visibility:hidden;
font-weight:bolder;
}
#info-sign:hover .text {
visibility:visible;
color:red;
}
"
)
)),
selectInput(
"Input",
label = tags$span("Input"),
choices = c("a", "b")
),
# HTML for the info sign
tags$div(
id = 'info-sign',
class = "glyphicon glyphicon-info-sign",
tags$span(class = "text", tags$p("formatted"))
)
),
server = function(input, output) {
}
)
英文:
Here is a possibility without using shinyBS
: Add the info sign as a separate div
and add the corresponding HTML
and CSS
separately. Then you can fully customise the displayed text when hovering the info sign.
library(shiny)
shinyApp(
ui = fluidPage(
tags$head(tags$style(
HTML(
"
#info-sign {
margin-left:40px;
margin-top:3px;
position: absolute;
}
#info-sign .text {
position:absolute;
bottom:-5px;
left:20px;
visibility:hidden;
font-weight:bolder;
}
#info-sign:hover .text {
visibility:visible;
color:red;
}
"
)
)),
selectInput(
"Input",
label = tags$span("Input"),
choices = c("a", "b")
),
# HTML for the info sign
tags$div(
id = 'info-sign',
class = "glyphicon glyphicon-info-sign",
tags$span(class = "text", tags$p("formatted"))
)
),
server = function(input, output) {
}
)
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论