Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to center a gwt application in the middle of the page

Tags:

css

gwt

I am trying to center a gwt application in the middle of the page,I have tried the following.

public void onModuleLoad() {
            RootPanel rootPanel = RootPanel.get();

            Image image = new Image("images/board.png");


            FlowPanel fp = new FlowPanel();

            fp.add(image);
            fp.setStyleName("center");
            rootPanel.add(fp);

        }

I have a .center in my stylesheet within the gwt application that has the following.

.center{
    margin: 0px auto;
    width: 480px;
}

But this seems not to work.

like image 611
james Avatar asked Dec 08 '10 05:12

james


1 Answers

You can probably try;

HTML;

<head>
      <style type="text/css">
    div#container
{
 margin-left: auto;
 margin-right: auto;
 width:480px;
}
        </style>

<script language="javascript" src="com.mycompany.project.TEST/com.mycompany.project.TEST.nocache.js"></script>

</head>

<body>
<div id="container" align="center">


</div>
</body>

onmoduleLoad;

public void onModuleLoad() {
        RootPanel rootPanel = RootPanel.get("container");

        Image image = new Image("images/board.png");


        FlowPanel fp = new FlowPanel();

        fp.add(image);
        fp.setStyleName("center");
        rootPanel.add(fp);

    }
like image 128
Yusuf K. Avatar answered Nov 15 '22 05:11

Yusuf K.