我在Shiny R应用中使用splitLayout
来创建一个双面板结构,左侧有一个绘图(googleVis
gVisGeoChart
个对象)和HTML右边。
这是有问题的代码的模型:
splitLayout(
htmlOutput("mychart"), #This winds up rendering properly to the left side of the window
div(
h1("A descriptive heading"),
p("Here's some text that takes more than one line on the screen. I want it to wrap, but it just keeps going to the right out of view in its container.")
) #This text will not wrap to the right side of the splitLayout frame
)
p()命令中的文本不会换行到splitLayout创建的页面的可见(1/2)。相反,它继续向(不可见)右侧,要求用户滚动查看全部。这不是理想的行为(坦率地说,我很难想象它的情况)。
如何确保文本正确包装到splitLayout区域?
答案 0 :(得分:2)
添加style = "word-wrap: break-word;"
:
p("Here's some text that takes more than one line on the screen. I want it to wrap, but it just keeps going to the right out of view in its container.",
style = "word-wrap: break-word;")
答案 1 :(得分:2)
超级老了,但我一直坚持这个问题一段时间,之前的回答没有用。最后通过一些html检查得出结论。你需要在splitLayout中添加一个样式元素,即:'white-space:normal',(默认情况下,它设置为'white-space:nowrap',用于splitLayout)。请参阅下文,了解原始问题的背景。
splitLayout(
htmlOutput("mychart"), #This winds up rendering properly to the left side of the window
div(
h1("A descriptive heading"),
p("Here's some text that takes more than one line on the screen. I want it to wrap, but it just keeps going to the right out of view in its container.")
),
cellArgs = list(style='white-space: normal;')
)