CSS class definition doesn't work inside <g:HTML> element

蓝咒 提交于 2019-12-10 13:56:53

问题


Could you guys tell me why css class definition doesn't work in following example ?

I'm using GWT 2.4 + Chrome 17.

<ui:UiBinder xmlns:ui='urn:ui:com.google.gwt.uibinder'
             xmlns:g='urn:import:com.google.gwt.user.client.ui'>
    <ui:style>
        div.test {
            color: red;
        }
    </ui:style>
    <g:HTML>
        <div class="test">I should be red but I'm not</div>
    </g:HTML>
</ui:UiBinder>

回答1:


CSS classes listed in the <ui:style> will be obfuscated, going from test to GKYSKJX (or something similar).

Update your div to this:

<div class="{style.test}">Now I'm red :)</div>

Alternatively, you could choose to force your style to NOT obfuscate by doing this:

@external .test;
div.test {
    color: red;
}

Unless you have a good reason, I recommend sticking with the first method.

See more at Declarative Layout with UiBinder - Hello Stylish World.



来源:https://stackoverflow.com/questions/9355498/css-class-definition-doesnt-work-inside-ghtml-element

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!