2012-04-10 35 views
1

在我的网页中,我有一个菜单(HorizontalPanel),它应该被锁定到页面的按钮。为此,我尝试使用RootLayoutPanel类,并在其中添加了一个南部小部件,并且我成功完成了这个任务。但问题是菜单不居中。 我尝试添加另一个CSS中,我写了(并注意位置):删除由GWT生成的绝对位置

.cetrer { 
    Margin-left : auto; 
    margin-right: auto; 
    position: relative; 
} 

但是当页面redered,位置由GWT设置为绝对的。 我试图通过将此河旁的代码强制的位置,但它没有工作:

DOM.setElementAttribute(menuBar.getElement(), "style", "position: relative;"); 

那么,有没有解决办法来解决? 谢谢

回答

1

您是否试过加入!important;? 赞:

.cetrer { 
    Margin-left : auto; 
    margin-right: auto; 
    position: relative !important; 
} 

虽然不是最好的解决方案。

+0

Waw!非常感谢解决方案,但是来自W3C的这个标签(!important)还是由GWT社区制作的? – 2012-04-10 21:03:27

+0

与GWT无关,自CSS1以来一直在CSS中:)。虽然这个解决方案既快速又肮脏,但我建议您了解如何使用GWT来实现。 – Ray 2012-04-10 21:09:54

+0

啊!好的,我找到了这个链接http://webdesign.about.com/od/css/f/blcssfaqimportn.htm。非常感谢你的帮助。 – 2012-04-10 21:10:47