0

I'm developing an app using mgwt.I'm having an horizontal panel which is added with two mgwt buttons. MGWT's layout panel is the parent(i.e;asWidget()returning layoutPanel). Now I want to make my hPanel exactly center to the layout panel. I dont want to read device width and using margins anymore.I want to done this through styles. I've done as below.But not succeeded. my current result is, hPanleButtons is displaying at left side of window but not at center.

    DOM.setStyleAttribute(hPanelButtons.getElement(), "cssAlign", "center");
    DOM.setStyleAttribute(hPanelButtons.getElement(), "styleAlign", "center");
    DOM.setStyleAttribute(layoutPanel.getElement(), "cssAlign", "center");
    DOM.setStyleAttribute(layoutPanel.getElement(), "styleAlign", "center"); 
hPanelButtons.getElement().setAttribute("style", "align:center");

i tried using all above individually but no use. please help me on this. Thanks in advance.

1 Answers1

0

finally I achieved my goal.I'm posting the answer so that it'll be useful to people who are facing the same requirement. I used DOM style attributes for doing this. Here is my code:

DOM.setStyleAttribute(hPanelButtons.getElement(), "marginLeft", "auto");
DOM.setStyleAttribute(hPanelButtons.getElement(), "marginRight", "auto");
DOM.setStyleAttribute(hPanelButtons.getElement(), "marginTop", "auto");
DOM.setStyleAttribute(hPanelButtons.getElement(), "marginBottom", "auto");

its working fine.