简体   繁体   English

对齐 GWT 中 SimplePanel 中的内容

[英]Align the content in SimplePanel in GWT

Anyone know how to put something in the center of SimplePanel or at least to arrange it somehow.任何人都知道如何将一些东西放在 SimplePanel 的中心,或者至少以某种方式安排它。

with HorizontalPanel adn VerticalPanel i could use setHorizontalAlignment() /setVerticalAlignment() but i am not able to find anything useful for SimplePanel.使用 HorizontalPanel 和 VerticalPanel 我可以使用 setHorizontalAlignment() /setVerticalAlignment() 但我找不到任何对 SimplePanel 有用的东西。

I know that SimplePanel can have only one widget, but im required to use it.我知道 SimplePanel 只能有一个小部件,但我需要使用它。

Any advice?有什么建议吗?

Thanks谢谢

If you use UIBinder this should work如果你使用 UIBinder 这应该可以工作

 <ui:style>
  .container {
     width:100%;
 }
 .content {
     width:200px;
     margin: 0 auto;
 }
</ui:style>
<g:SimplePanel addStyleNames="{style.container}">
    <g:HTMLPanel addStyleNames="{style.content}">
     <!-- CONTENT -->
    </g:HTMLPanel>
</g:SimplePanel>

Create Horizontal/Vertical panel.创建水平/垂直面板。 Add widget with required alignment.添加具有所需 alignment 的小部件。 Add this panel to the SimplePanel.将此面板添加到 SimplePanel。

You can also probably achieve it by tweaking the CSS instead of having an extra panel您也可以通过调整 CSS 而不是额外的面板来实现它

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM