How can I vertically center an element with GWT?

前端 未结 3 1027
被撕碎了的回忆
被撕碎了的回忆 2021-02-09 17:52

Perhaps I haven\'t been searching the right way but I cannot figure out for the life of me how to center an element using GWT Layout Panels.

I\'m using UiBinder and I\'v

相关标签:
3条回答
  • 2021-02-09 18:02

    Have you tried setting width less than 100% ... i feel the width of HorizontalPanel becomes 100% ... so it occupies whole DockLayoutPanel and thus the FlexTable might be getting left aligned.

    0 讨论(0)
  • 2021-02-09 18:07

    Centering an item can be done with a cell element like this:

    <g:HorizontalPanel width="100%" height="100%">
     <g:cell horizontalAlignment="ALIGN_CENTER" verticalAlignment="ALIGN_MIDDLE">
      <g:Label>Hello Center</g:Label>
     </g:cell>
    </g:HorizontalPanel>
    
    0 讨论(0)
  • 2021-02-09 18:10

    You can use styleName attribute in your component. For Example:

    <g:DockLayoutPanel>
    <g:center>
        <g:HorizontalPanel width="100%" height="100%" >
            <g:FlexTable ui:field="homeData" styleName="verticalAlign"/>
        </g:HorizontalPanel>
    </g:center>
    </g:DockLayoutPanel>
    

    and have

    .verticalAlign{
    vertical-align: middle;
    }
    

    in your style.css

    0 讨论(0)
提交回复
热议问题