如何设置背景图像url高度和宽度的样式
我正在使用sencha-touch和构建一个mobileApp,我有一个带有图像的视图- Xtype
var profilePicture = {
xtype : 'image',
style : 'margin-top:10px;',
id : 'profilePhoto',
src : 'resources/images/profile.png',
height : '104px',
width : '84px'
};
我将此图像添加到面板中,并在控制器中使用从服务器获得的json值动态设置图像的src。
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。我的图片的大小是1600px×1200px,所以它不适合上面的div。是否可以设置背景图像url的样式?我可以做什么,以样式的图像是来自于网址?
发布于 2012-10-19 19:37:38
使用CSS3 -
div{ background-size: cover; }
因为您在web应用程序中使用大图像。你应该在上阅读
https://stackoverflow.com/questions/12973351
复制相似问题