You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在Shiny应用中为文本添加边框

修改后的实现代码如下:

library(shiny)
library(shinythemes)

ui <- shiny::navbarPage(theme = shinytheme("flatly"),
                        title="Test", collapsible = TRUE,
                        
                        tabPanel("",
                                 
                                 div(
                                   style = 
                                     "height: 80px; background-color: #02BE7F; width: 100%; position: absolute; right:0;",
                                   h2(HTML("Project <b>Description</b>"), 
                                      style="text-align:center;color: white"),
                                   hr(),
                                   
                                   div(
                                     style = "width: 70%; margin: 100px auto 0; border: 1px solid #ddd; border-radius: 6px; padding: 24px;",
                                     h2(HTML("Lorem Ipsum is simply dummy text of the printing and typesetting industry. 
                                      Lorem Ipsum has been the industry's standard dummy text ever since the 1500s"), 
                                        style="text-align:justify")),
                                   tags$style(".navbar {margin-bottom: 0;}")
                                 )
                                 
                        ))

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

shinyApp(ui = ui, server = server)

主要修改点是在文本外层div的样式中增加了border边框、border-radius圆角、padding内边距,同时调整了上外边距避免文本被顶部的绿色标题栏遮挡,边框样式和参考图效果一致。

参考样式图:
样例参考图片

内容的提问来源于stack exchange,提问作者user16774617

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.06 04:57:04