2010-04-23 47 views
3

我正在遷移到使用CssResource。 不過,我不知道如何使用前綴類型:(...是這樣的:CssResource的例子?

.prefix .label { 
padding: 10px; 
} 

.prefix .button { 
padding: 20px; 
} 

我該怎麼改造這個到CssResource類和使用它的代碼:(... 我與@Import@ImportedWithPrex@Share打,但是這一切都有點混亂和文檔很難理解:(... 請一些幫助

埃德

+1

我碰到的,我已經得到了同樣的問題.myClass {...}和.myClass .gwt-Label {...}。我想將其轉換爲CssResource,但.gwt-Label導致問題 – 2010-08-18 16:37:21

回答

1

下面是一些代碼,演示ImportedWithPrefix一個的使用情況? nnotation

interface Bundle extends ClientBundle { 
    @Source("CssImportScopeSample.css") 
    InnerStyle innerStyle(); 

    @Source("CssImportScopeSample.css") 
    OuterStyle style(); 
    } 

    @ImportedWithPrefix("inner") 
    interface InnerStyle extends Style { 
    } 

    @ImportedWithPrefix("outer") 
    interface OuterStyle extends Style { 
    } 

    interface Style extends CssResource { 
    String body(); 
    } 

和一個小UiBinder的代碼..

<ui:UiBinder xmlns:ui='urn:ui:com.google.gwt.uibinder' > 
    <ui:with field='bundle' type='com.google.gwt.uibinder.test.client.CssImportScopeSample.Bundle' /> 

    <ui:style import='com.google.gwt.uibinder.test.client.CssImportScopeSample.OuterStyle 
     com.google.gwt.uibinder.test.client.CssImportScopeSample.InnerStyle'> 
    .outer-body .inner-body { width: 100px; background-color: red; } 
    </ui:style> 

    <div class='{bundle.style.body}'> 
    <span ui:field='outer'/> 
    <div ui:field='inner' class='{bundle.innerStyle.body}'>Inner!</div> 
    </div> 
</ui:UiBinder> 

希望這得是你在正確的軌道上....

+0

謝謝,但是您能否回答我的具體情況,因爲您的情況非常不同。 我不明白如何在我的代碼中使用樣式「.prefix .button」。 – edbras 2010-04-24 11:09:43