简体   繁体   English

GWT-第一步-Div + label + css样式

[英]GWT - First Steps - Div+label+css style

Im starting making an application with GWT. 我开始用GWT制作应用程序。 Now, i use the AbsolutePanel widget to describe a "div". 现在,我使用AbsolutePanel小部件来描述“ div”。 After this, i create a label (should be a span?), i add to this panel and i apply a css class to the div. 之后,我创建一个标签(应该是一个跨度?),将其添加到此面板中,然后将一个CSS类应用于div。

this is the code : 这是代码:

public void onModuleLoad() {
    AbsolutePanel contenitore = new AbsolutePanel();
    final Label label = new Label("Hello, GWT!!!");
    contenitore.setStyleName("contenitore");
    contenitore.add(label);

}

// css
body {background:#999999;}
.contenitore{ background-color:#333333; width:980px; margin-left:auto; margin-right:auto; overflow:auto;}

Unfortunatly, it don't get the css propiety of the div, and i cant see the label. 不幸的是,它没有得到div的css属性,我看不到标签。 Why? 为什么? And, there are any change to see (im using the gwt debug on netbeans) which is the generated html code? 并且,有什么变化要查看(即在netbeans上使用gwt调试),这是生成的html代码吗? cheers 干杯

Some tips on your example: 您的示例的一些提示:

  • add the AbsolutePanel to the RootPanel AbsolutePanel添加到RootPanel
RootPanel.get().add(contenitore);
  • the Label class creates a <div> element. Label类创建一个<div>元素。 If you're looking for a <span> check out InlineLabel 如果您要查找<span>请查看InlineLabel

  • to see how to deal with css in GWT check this out or have a look at UiBinder 看看如何在GWT中处理CSS,请查看此内容或查看UiBinder

Hope that helps. 希望能有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM