简体   繁体   English

GWT:带框架的网站布局

[英]GWT: Site layout with frames

I'm not really a web developer so please excuse me if my vocabulary is kind of limited. 我不是真正的Web开发人员,所以如果我的词汇量有限,请原谅。

What I want to do is to create a header and a main-content panel. 我想要做的是创建一个标题和一个主要内容面板。 The main content panel should contain a menu on the left side and scrollable. 主内容面板应在左侧包含一个菜单并且可以滚动。 The header on the other hand shall be fixed. 另一方面,报头应该是固定的。 The menu on the left side is also supposed to reside statically on its vertical position next to the content panel. 还应该将左侧菜单静态放置在内容面板旁边的垂直位置。

|- - - - - - - - - - - - - - -|
| Header (fixed)              |
|- - - - - - - - - - - - - - -|
|          |                | |
| | - - - -|                | |
| | Menu   |                | |
| |(fixed) |  Main-Content  | |
| |        |  (scrollable)  | |
| |- - - - |                | |
|          |                | |
|          |                | |
|- - - - - |- - - - - - - - |-|

The thing is that I'm having already troubles witht the header. 问题是我已经在头文件方面遇到麻烦了。 I've used this: 我用了这个:

<ui:style>
    .home_header {
    background-color: #FFC400;
    margin:0px;
    width:100%;
    height:90px;
    position: relative;
    }

    .home_main {
    margin-top:90px;
    }
</ui:style>

<g:VerticalPanel width="100%" height="100%">

    <!-- For now this is empty -->
    <g:DeckPanel ui:field="headerPanel" styleName="{style.home_header}">
    </g:DeckPanel>

    <g:HorizontalPanel horizontalAlignment="ALIGN_CENTER" width="100%" styleName="{style.home_main}">
        <g:ScrollPanel>
            <g:DockPanel>
                <g:Dock direction="CENTER">
                    <g:HTMLPanel ui:field="mainContentPanel" width="1024px" height="1005"> 
                    ...
                    </g:HTMLPanel>
                </g:Dock>
            </g:DockPanel>
        </g:ScrollPanel>

    </g:HorizontalPanel>
</g:VerticalPanel>

and I'm setting the position of the header like this: 并且我像这样设置标题的位置:

public UIHome() {
    initWidget(uiBinder.createAndBindUi(this));     
    Window.addWindowScrollHandler(new Window.ScrollHandler() {
        @Override
        public void onWindowScroll(
                com.google.gwt.user.client.Window.ScrollEvent event) {
            headerPanel.getElement().getStyle().setTop(event.getScrollTop(), Unit.PX);
        }
    });
}

But the problem here on the one hand is that the footer is flickering on the one hand and the content gets displayed above it if one scroll down. 但是,这里的问题是一方面,页脚闪烁,如果向下滚动,内容将显示在其上方。

I was not thinking if I should use something like a frameset but I am not sure if that's the way to go here. 我没有在考虑是否应该使用框架集之类的东西,但是我不确定这是否是可行的方法。

Any suggestions how I could set up this layout? 有什么建议可以设置这种布局吗?

Isn't this the exact use case for DockLayoutPanel ? 这不是DockLayoutPanel的确切用例吗? You can see it in action in the Showcase . 您可以在Showcase中看到它的运行情况。

In terms of UiBinder, it'd look something like this : 就UiBinder而言,它看起来像这样

<g:DockLayoutPanel unit='EM'>
  <g:north size='5'>
    <g:DeckPanel ui:field="headerPanel" styleName="{style.home_header}" />
  </g:north>
  <g:center>
    <g:ScrollPanel>
        <g:HTMLPanel ui:field="mainContentPanel" width="1024px" height="1005"> 
            ...
        </g:HTMLPanel>
    </g:ScrollPanel>
  </g:center>
  <g:west size='192'>
    <g:HTML>
      <ul>
        <li>Sidebar</li>
        <li>Sidebar</li>
        <li>Sidebar</li>
      </ul>
    </g:HTML>
  </g:west>
</g:DockLayoutPanel>

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

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