大虾: 有没有办法让一个盒子里的所有内容垂直对齐?
我试图将一些内容垂直居中放置在边界框中。对于单个文本,这没有问题:
bounding_box([0, bounds.top], :width => pdf.bounds.right, :height => pdf.bounds.top) do
text "vertically aligned in the surrounding box", :valign => :center
end
但是,如果我的边界框中有多个元素,我该怎么办:
bounding_box([0, bounds.top], :width => pdf.bounds.right, :height => pdf.bounds.top) do
text "vertically aligned in the surrounding box", :valign => :center
text "vertically aligned in the surrounding box", :valign => :center
end
那行不通,当您尝试此操作时,文本会被覆盖...
我正在寻找一种分组方法bounding_box 的全部内容,然后垂直对齐整个组。有没有什么办法可以用虾来做这个?
非常感谢您的帮助! 克里斯
I'm trying to position some content vertically centered in a bounding_box. With a single text this is no problem:
bounding_box([0, bounds.top], :width => pdf.bounds.right, :height => pdf.bounds.top) do
text "vertically aligned in the surrounding box", :valign => :center
end
But what can I do if a have multiple elements in my bounding box:
bounding_box([0, bounds.top], :width => pdf.bounds.right, :height => pdf.bounds.top) do
text "vertically aligned in the surrounding box", :valign => :center
text "vertically aligned in the surrounding box", :valign => :center
end
That won't work, the text is overlaid when you try this...
I'm looking for a way to group the whole content of the bounding_box and then align that whole group vertically. Is there any way to do this with prawn??
Thanks a lot for your help!
Chris
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您只有文本行,您仍然可以在文本中使用
formatted_text
和\n
:我仍在尝试找出如何处理图片/图例组,因为即使是桌子似乎也不起作用。
If you only have text lines, you can still use
formatted_text
with\n
in your text :I'm still trying to figure out how to handle a picture/legend group, since even tables don't seem to do the trick.