我splitLayout在Shiny R应用程序中使用它来创建一个两面板的结构,该结构的左侧为图(一个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
)
Run Code Online (Sandbox Code Playgroud)
p()命令中的文本不会换成由splitLayout创建的页面的可见(1/2)。取而代之的是,它一直指向(不可见的)右侧,要求用户滚动查看所有内容。这不是理想的行为(坦率地说,我很难想象它的情况)。
如何确保文本正确包装到splitLayout区域?
小智 5
超级老,但我在这个问题上停留了一段时间,以前的答案没有用。终于通过一些html检查弄清楚了。您需要在splitLayout中添加一个样式元素,即:'white-space:normal',(默认情况下,将splitLayout设置为'white-space:nowrap')。请参阅以下内容,将其与原始问题结合使用。
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;')
)
Run Code Online (Sandbox Code Playgroud)
添加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;")
Run Code Online (Sandbox Code Playgroud)