我如何更改我的GWT默認列表框的樣式。 以我應用程序中的每個列表框都會改變的方式。如何更改我的GWT列表框樣式
不應該工作嗎?
.gwt-ListBox{
color: red !important;
}
感謝。
我如何更改我的GWT默認列表框的樣式。 以我應用程序中的每個列表框都會改變的方式。如何更改我的GWT列表框樣式
不應該工作嗎?
.gwt-ListBox{
color: red !important;
}
感謝。
.............................................. ....
嗨,現在這樣做了寫
body .gwt-ListBox{
color: green !important;
}
.gwt-ListBox{
color: red !important;
}
二是
定義您body id
像這樣
HTML
<body id="someid">
<div class="gwt-ListBox">
some text
</div>
</body>
的CSS
#someid .gwt-ListBox{
color:green !important;
}
只有一個body元素,爲什麼要爲它添加一個id?根本沒有必要使用
- 您可以直接設計此加入你的CSS文件,如果你想改變所有列表,當你在你的問題說:
select {
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"); } } } }
命中如果這對你有用!
用於此............... body .gw-ListBox {color:red!important} –