简体   繁体   English

想从我的java代码中访问css样式

[英]want to access the css styles from my java code

i have a css in my GWTApplication which contains several classes in that,I want to access the class attributes through my program,is there any way to access them via java code or CssResource. 我在我的GWTApplication中有一个css,其中包含几个类,我想通过我的程序访问类属性,有没有办法通过java代码或CssResource访问它们。 If there is any let me know with the sample code? 如果有任何让我知道示例代码?

One can access CSS classes through GWT code but not its class attributes through setStyleName(String) method. 可以通过GWT代码访问CSS类,但不能通过setStyleName(String)方法访问其类属性。 For example 例如

Button button = new Button();
button.setStyleName("Stylename");

for example css of 例如,css

.StyleName {
 background : #abcdef;
 }

Further you can change the value of some attributes without css like 此外,您可以在不使用css的情况下更改某些属性的值

button.setWidth("100px");
button.setHeight("20px");

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

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