Wednesday, April 23, 2014

Re: DockLayoutPanel as root with fixed width

I see such sites very often: a fixed-width layout but with still some content in the remaining space.

So the root layout panel should cover the whole viewport.

I don't get it. What remaining space do you mean and why should something fill the whole viewport in a fixed-width layout? In a fixed-width layout the whole point is that your page has a defined width, which in most cases is 960px, and possible remaining space left and right of that 960px page is intentionally empty so that users don't have to scroll horizontally if they use a small screen, e.g. 1024x768. 

So maybe you don't mean a fixed-width layout? If you really meant it then your outer most container should have a fixed width, which in case of GWT would be the container widget you put into the RootPanel (which represents the <body> tag). In case of RootLayoutPanel it would be the RootLayoutPanel itself, as it puts itself into the RootPanel behind the scenes.

So you either have

FlowPanel fixedWidthPage = new FlowPanel(); // or any other widget
fixedWidthPage.setWidth("960px");
fixedWidthPage.getElement().getStyle().setProperty("margin","auto");
RootPanel.get().add(fixedWidthPage);

or

DockLayoutPanel page = new DockLayoutPanel(); // or any other layout widget
RootLayoutPanel fixedWidthRootLayoutPanel = RootLayoutPanel.get();
fixedWidthRootLayoutPanel.setWidth("960px");
fixedWidthRootLayoutPanel.getElement().getStyle().setProperty("margin","auto");



-- J.

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment