如何更改我的 GWT 默认列表框的样式。 我的应用程序中的每个列表框都会发生变化。
这不可行吗?
.gwt-ListBox{
color: red !important;
谢谢。
最佳答案
如果您想以编程方式执行此操作,那么这就是我实现它的方法..
在这个特定的代码片段中,我设置了一个的背景颜色 列表框中的特定元素(名为 ABC 的元素)变为红色。
但是你明白了,一旦你有了选项元素,你就可以随心所欲地做。
--- 创建并填充列表框
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"); } } } }
如果这对您有用,请点赞!
关于css - 如何更改我的 GWT 列表框样式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12403861/