if(a.width/a.height>w/h){
thisp.height=w*a.height/a.width; /*不对图片拉伸*/
thisp.width=w;
var last_h=h-thisp.height
var margin_h=last_h/2;
thisp.style["paddingTop"]=margin_h;
thisp.style["paddingBottom"]=margin_h;
}else{
thisp.width=h*a.width/a.height;
thisp.height=h;
var last_w=w-thisp.width
var margin_w=last_w/2;
thisp.style["paddingLeft"]=margin_w;
thisp.style["paddingRight"]=margin_w;
}
在IE下全正常的,但在火狐中不起作用。
------解决方案--------------------
不太懂你这个效果!
------解决方案--------------------
- JScript code
thisp.height=w*a.height/a.width + 'px'; /*不对图片拉伸*/ thisp.width=w + 'px';