我想将CustomScrollPanel设置为高度100%;我试图将CustomScrollPanel的高度设置为100%,但这种方式无法正常工作。这是我想尝试的。

public class MyScrollPanel extends Composite implements HasWidgets {

private ResizeLayoutPanel resizeLayoutPanel;
private CustomScrollPanel customScrollPanel;


public MyScrollPanel() {
    resizeLayoutPanel = new ResizeLayoutPanel();
    resizeLayoutPanel.setStyleName(resources.css().resizeLayoutPanel());
    customScrollPanel = new CustomScrollPanel();
    customScrollPanel.addStyleName(resources.css().customScrollPanel());


    resizeLayoutPanel.add(customScrollPanel);
    initWidget(resizeLayoutPanel);
}


我的CSS:

.resizeLayoutPanel {
   height: 100%;
   background-color: yellow;
}


如何使CustomScrollPanel高度达到100%?

最佳答案

除非父div具有固定的高度(如height:100%),否则height:500px将不起作用。

最好的方法是计算窗口/父容器的高度,并将其分配给div元素,并在运行时调整大小。

10-08 08:00