How to use ScrollPanel with relative size

前端 未结 3 1513
别那么骄傲
别那么骄傲 2021-01-17 02:55

I\'m trying to use a ScrollPanel of GWT in a page. Since most of the contents are in the ScrollPanel, I want it to take an as-large-as-possible part of the page and resize a

3条回答
  •  独厮守ぢ
    2021-01-17 03:37

    The answer to your first question is very simple. When using the relative size for an element you are referring to the size of a parent element. So when you set height: 100% it means that your element should be 100% size of its parent.

    And there are some ways to get what you want:

    • use the Viewport-percentage lengths - you can set height: 100vh which means 100% of the viewport height - this is the easiest way but may be not yet supported by all browsers

    • set both the html and body elements 100% height - this will allow you to use the relative height on child elements

    • use GWT DockLayoutPanel or DockPanel and add your scroll panel to the center pane - it will take all the remaining space

提交回复
热议问题