浅谈 sencha 2.0 中image和carousel的图片自适应大小的应用
在sencha 2.0中,经常会用到xtype:image, 但是这个类型的使用,它的表现形式都是一个<div>,然后给把我们要显示的图片作为背景图片放入这个div中,这样,我们往往不好设置它的大小,因为图片是背景图片,高宽都不如<img>标签进行控制的好。
尤其是当我们使用xtype:carousel这个类型时,如果代码是这样:
xtype: 'carousel',items: [{ xtype: 'panel', html:"<img src='http://192.168.1.1/image.jpg' style='max-height:200px;max-width:200px'>"},{ xtype: 'panel', html:"<img src='http://192.168.1.1/image.jpg' style='max-height:200px;max-width:200px'>"}]
这样把max-height和max-width设置为carousel的大小,那么图片就会自动缩放