cssgwtgquery

"Sticky" panel on a Gwt application


I have a GWT app that have a HorizontalPanel that span across the width of the page, that serves as the "top bar" of the app. However I want to make it "sticky" that is when the page content grows, and when scrollbar appears, when scrolled I want the said HorizontalPanel to stick on top. Is it possible to do with GWT and/or with the help of GQuery?


Solution

  • By using CSS:

    Add/set a css class to your HorizontalPanel

    myHorizontalPanel.setStyleName("onTop");
    

    In you css file:

    .onTop{
      position: fixed;
      top: 0px;
      left: 0px;
      /* adapt width and heigth to fit your needs */
      width:100%;
      height:40px;
    }
    

    That should do the trick