Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/gwt/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Css 如何更改我的GWT列表框样式_Css_Gwt - Fatal编程技术网

Css 如何更改我的GWT列表框样式

Css 如何更改我的GWT列表框样式,css,gwt,Css,Gwt,如何更改GWT默认列表框的样式。 在某种程度上,我的应用程序中的每个列表框都会发生变化 这不管用吗 .gwt-ListBox{ color: red !important; } 谢谢。 嗨,现在把这个重写一遍 body .gwt-ListBox{ color: green !important; } .gwt-ListBox{ color: red !important; } 第二个是 定义您的主体id 像这样 html <body id="someid">

如何更改GWT默认列表框的样式。 在某种程度上,我的应用程序中的每个列表框都会发生变化

这不管用吗

 .gwt-ListBox{
color: red !important;
}


谢谢。

嗨,现在把这个重写一遍

   body .gwt-ListBox{
color: green !important;

}


.gwt-ListBox{
color: red !important;

}


第二个是

定义您的
主体id

像这样

html

<body id="someid">
<div class="gwt-ListBox">
some text
</div>

</body>

如果您想更改所有列表,请将其添加到CSS文件中,如您在问题中所述:

select {
    color: red !important;
}

如果你想通过编程来实现这一点,那么下面是我如何实现的

在这段代码中,我设置了一个的背景颜色 列表框中的特定项(名为ABC的项)变为红色

但是你有了这个想法,一旦你有了选项元素,你就可以随心所欲了

---创建并填充列表框

--下面是如何设置特定项目的样式

nodelistchildren=listBox.getElement().getChildNodes();
for(int i=0;i

如果这对你有用的话,就这样打吧

习惯于。。。。。。。。。。。。。。。body.gw列表框{color:red!important}只有一个body元素,为什么要向其中添加id?根本不需要使用-您可以直接设置样式。
select {
    color: red !important;
}
ListBox listBox;
listBox.addItem("123");
listBox.addItem("ABC");
NodeList<Node> children = listBox.getElement().getChildNodes();       
    for (int i = 0; i< children.getLength();i++) {
      Node child = children.getItem(i);
        if (child.getNodeType()==Node.ELEMENT_NODE) {
          if (child instanceof OptionElement) {
            OptionElement optionElement = (OptionElement) child;
              if (optionElement.getValue().equals("ABC")) {
                 optionElement.getStyle().setBackgroundColor("red");  
              }                   
            }
          }           
       }