如何在Shiny的popover中同时实现标题与列表文本两端对齐?
解决方法
要同时实现popover标题两端对齐并保留列表的原有格式,只需在CSS样式里分别指定标题和列表的规则即可:
- 针对popover标题对应的CSS类
popover-title添加text-align: justify属性 - 保留原有针对
popover ul的样式设置
修改后的完整代码如下:
library(shiny) library(shinyBS) ui <- fluidPage( tags$style(' .popover-title {text-align: justify;} .popover ul {padding: 15px; text-align: justify;} '), br(), uiOutput("uiExample") ) server <- function(input, output, session) { output$uiExample <- renderUI({ tagList( tags$span("Little circle >>"), tags$span( popify( icon("info-circle", verify_fa = FALSE), "Placeholder", paste( "Here is an excerpt from a famous poem Still I Rise:", "<ul>", "<li>You may write me down in history With your bitter, twisted lies,</li>", "<li>You may tread me in the very dirt. But still, like dust, I will rise.", "Does my sassiness upset you...</li>", "</ul>" ) ) ) ) }) } shinyApp(ui, server)
说明
.popover-title是shinyBS中popover标题的专属容器类,单独设置它的文本对齐不会干扰其他元素- 原有的
ul样式规则完全保留,列表的内边距和两端对齐格式都能维持不变
内容的提问来源于stack exchange,提问作者Village.Idyot
相关产品推荐
相关产品推荐

