【发布时间】:2010-04-20 22:53:02
【问题描述】:
这篇文章只涉及 IE。 以下代码的最后一行导致了问题。
int width = 200;
int height = 200;
int overHeight = 40;
AbsolutePanel absPanel = new AbsolutePanel();
absPanel.setSize(width + "px", height + "px");
SimplePanel underPanel = new SimplePanel();
underPanel.setWidth(width + "px");
underPanel.setHeight(height + "px");
underPanel.getElement().getStyle().setBackgroundColor("red");
SimplePanel overPanel = new SimplePanel();
overPanel.setWidth(width + "px");
overPanel.setHeight(overHeight + "px");
overPanel.getElement().getStyle().setBackgroundColor("black");
//Setting the IE opacity to 20% on the black element in order to obtain the see through effect.
overPanel.getElement().getStyle().setProperty("filter", "alpha(opacity=20)");
absPanel.add(underPanel, 0, 0);
absPanel.add(overPanel, 0, 0);
RootPanel.get("test").add(absPanel);
//The next line causes the problem.
absPanel.getElement().getStyle().setProperty("filter", "alpha(opacity=100)");
所以基本上这段代码应该显示一个 200 像素 x 200 像素的红色正方形(参见代码中的 underPanel),并在其顶部显示一个 200 像素 x 40 像素的黑色矩形(参见代码中的 overPanel)。然而,黑色矩形是部分透明的,因为它的透明度设置为 20%,因此它应该显示为红色,但比位于下方的矩形更深,因为它实际上是一个褪色的黑色项目。
由于最后一行代码将包含的 AbsolutePanel 的不透明度设置为 100%(理论上这不会影响视觉结果),因此会出现一些渲染问题。事实上,在这种情况下,面板仍然可以看穿,但可以直接看穿页面的背景颜色!就好像坐在下面的面板根本不在那里......
有什么想法吗?
这是在 GWT 2.0 和 IE7 下。
【问题讨论】:
标签: css internet-explorer gwt transparency