R和Shiny - 侧边栏文本对齐方式调整为两端对齐

3
我创建了一个Shiny应用程序,您可以在此处查看:http://www.agristats.eu/en/prices-agricultural-commodities/ 该应用程序的R代码在这里。问题出在侧边栏的文本上,它一直隐藏在图表后面,因此我需要在侧边栏中将其对齐。相应的代码部分是:enter image description here
sidebar <- dashboardSidebar(sidebarMenu(selectInput('commodity', 'Προϊόν', 
    choices = unique(data_quandl$data_product)),
    tags$footer(tags$p("This application is based on Quandl data."))))

更加令人困惑的是,在同一个网站中,我有另一个类似的应用程序,相应的侧边栏文本被正确打印。您可以在此处查看正常运行的应用程序:这里。如何解决这个问题?
2个回答

4
footer 放在 sidebarMenu 外面就可以实现以下效果:
sidebar <- dashboardSidebar(sidebarMenu(
  selectInput('commodity', 'Προϊόν', choices = unique(data_quandl$data_product))
  ),
  tags$footer(
    tags$p("This application is based on Quandl data.")))

输出:

snap1

另一种解决方法是使用 div 标签来对齐文本。

sidebar <- dashboardSidebar(sidebarMenu(
  selectInput('commodity', 'Προϊόν', choices = unique(data_quandl$data_product)),
  div(style="text-align:center","This application is based on",br(), "Quandl Data")
  ))

这将导致以下结果:

snap2


1
你遇到的问题是,页脚出现在ul标签内部,这是由于ul上的{white-space:nowrap}规则引起的。
如果可能的话,请将页脚放在ul标签外面,这应该可以解决问题。
否则,尝试使用自定义CSS属性{white-space:initial;}。
希望这可以帮助你。

非常感谢您的回答。您的建议与@ParthChaudhary的建议非常相似,但他/她的表述更加清晰明了,因此我接受了他/她的建议。 - lios

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接