gpt4 book ai didi

java - 如何在 GWT 中设置固定位置面板?

转载 作者:行者123 更新时间:2023-11-30 11:49:06 24 4
gpt4 key购买 nike

我有一个位于 RootLayoutPanel.get() 中的大 SimpleLayoutPanel,这是一个约束。

现在我想放置一些额外的面板,并希望它在浏览器屏幕中具有 position:fixed 。可能吗?

我无法使用 setStyleName()/CSS 或 DOM.setStyleAttribute() 设置此样式。在这两种情况下,我的风格都被 GWT 压倒了

谢谢

我成功的代码

我同时使用了两个根面板

public void onModuleLoad() {

SimpleLayoutPanel simpleLayoutPanel = new SimpleLayoutPanel();
simpleLayoutPanel.setStyleName("SimpleLayoutPanel");

DOM.setStyleAttribute(simpleLayoutPanel.getElement(), "backgroundColor", "blue");

RootLayoutPanel rootLayoutPanel = RootLayoutPanel.get();
rootLayoutPanel.add(simpleLayoutPanel);

LayoutPanel layoutPanel = new LayoutPanel();
layoutPanel.setStyleName("LayoutPanel");
DOM.setStyleAttribute(layoutPanel.getElement(), "position", "fixed");
DOM.setStyleAttribute(layoutPanel.getElement(), "bottom", "0px");
DOM.setStyleAttribute(layoutPanel.getElement(), "height", "100px");
DOM.setStyleAttribute(layoutPanel.getElement(), "width", "100px");
DOM.setStyleAttribute(layoutPanel.getElement(), "backgroundColor", "red");

RootPanel rootPanel = RootPanel.get();
rootPanel.add(layoutPanel);


}

最佳答案

RootLayoutPanel 和RootPanel 可以同时使用。

这样我就成功了。我需要接收调整大小事件的元素已放入 RootLayoutPanel 中。我需要固定定位的元素已放入 RootLayout 中。

我发现没有办法将所有内容都放入一个根面板中。

关于java - 如何在 GWT 中设置固定位置面板?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8543768/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com