2012-10-19 38 views
0

如何風格的背景圖像的URL的高度和寬度造型背景圖片地址

我使用煎茶觸摸,建設一個MobileApp, 我有一個圖像的視圖 - 的xtype

var profilePicture = { 
     xtype : 'image', 
     style : 'margin-top:10px;', 
     id : 'profilePhoto', 
     src : 'resources/images/profile.png', 
     height : '104px', 
     width : '84px' 
    }; 

我在面板中添加了這個圖像 我動態地在我的控制器中設置圖像的src與我從服務器獲取的json的值,

src = localStorage.httpServerPrefix + profile.imageURI; //我得到圖像的URL Ext.getCmp(「profilePicture」)。setSrc(src。);

當我在瀏覽器 我得到這樣看,

<div class="x-img" id="profilePhoto" style="margin-top: 10px; height: 104px !important; width: 84px !important; background-image: url(http://127.0.0.1:8080/Milna/user/mphoto/1?version=7); "></div> 

高度和DIV的寬度設置爲104px和84px。 我的圖像的像素是1600×1200,因此它不適合上面的div, 我可以風格的背景圖像的網址? 我能做些什麼來設計來自url的圖像?

回答

1

看看這個Refactored scope。在這篇文章中,他解釋了造型功能。

你的造型會更一致,更重要的是它會讓你完全好看,當你restyle在幾分鐘而不是幾天整個移動應用程序。

風格:「背景:資源/圖像/ profile.png;寬度:45%」,

+0

哇,這是非常有用的,謝謝你vivek, – Sri

+0

歡迎@vaish如果你認爲我的答案是有用的接受它 –

1

使用CSS3 -

div{ background-size: cover; } 

當你在你的web應用程序中使用高畫質圖像。你應該閱讀Adaptive Images

+0

如Dipaks說,使用背景尺寸porperty。之後,您可以使用「background-position」屬性來正確定位背景圖像。 – Mak

+0

Thanku,它成功了,但圖像的一半是可見的高度:104和寬度:84,當我減少高度和寬度50px和50px我可以得到完整的形象,但我希望它有點大和fullImage。我能做什麼 ?? – Sri