【问题标题】:GWT Uibinder Image showing but not resizingGWT Uibinder 图像显示但不调整大小
【发布时间】:2010-11-18 17:02:27
【问题描述】:

此图像正在显示,但无论我使用的宽度或高度值如何,我都无法调整它的大小。有什么想法吗?谢谢。

<ui:with field='res' type='com.hellomvp.client.resources.MyResources'/>

    <ui:style>
        .fortaImage { width:'50px'; height:'50px';} 
    </ui:style>

    <g:DockLayoutPanel unit='EM'>
        <g:north size="10"> 
            <g:FlowPanel>
            <g:Image styleName='{style.fortaImage}' resource='{res.fortaLogo}'/>
            <g:InlineLabel>FortaService</g:InlineLabel>
            <g:ListBox></g:ListBox>
            <g:InlineLabel>DateIn</g:InlineLabel>
            <d:DateBox></d:DateBox>
            <g:InlineLabel>DateOut</g:InlineLabel>
            <d:DateBox></d:DateBox>
            <g:Button>Cerca</g:Button>

            </g:FlowPanel>
        </g:north>



    </g:DockLayoutPanel>

【问题讨论】:

  • 我在另一个帖子中对此进行了描述。它适用于来自 ClientBundle 资源 link 的图像

标签: gwt uibinder


【解决方案1】:

当您使用&lt;g:Image resource="..."/&gt; 时,GWT 使用背景图像。背景图像不能在 CSS 2.1 中调整大小。 (我真的希望这是可能的!)

您所能做的就是在服务器上保存一个 50x50px 版本的图像,或者改用 &lt;g:Image url="..."/&gt;。这将创建一个普通的&lt;img src="..."/&gt; 而不是背景图像,但您不能在此处指定 ClientBundle 资源。

【讨论】:

    【解决方案2】:
    addStyleNames="{style.fortaImage}"
    

    不是

    styleName='{style.fortaImage}'
    

    【讨论】:

    • styleName 和 addStyleNames 都可以。
    • 可能,但 styleName 会覆盖所有以前的类名,而不是添加额外的样式名。 “使用 styleName 属性覆盖小部件默认的 CSS 样式(就像在代码中调用 setStyleName() 一样)。或者,要添加类名而不破坏小部件的烘焙样式设置,请使用特殊的 addStyleNames 属性:“code.google.com/webtoolkit/doc/latest/…无论如何,这毕竟不是 OP 的问题。
    猜你喜欢
    • 2020-10-12
    • 1970-01-01
    • 2017-06-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-06-16
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多