style="background-color: rgb(255, 255, 255); -rave-layout: grid;background-attachment: fixed"
我设置了背景图片不动但是如果图片过大的话他只能显示图片的一部分,请问什么参数能把背景图片自动按浏览器适合宽度显示。
我设置了背景图片不动但是如果图片过大的话他只能显示图片的一部分,请问什么参数能把背景图片自动按浏览器适合宽度显示。
var image=new Image();
image.src=ImgD.src;
if(ImgD.src.indexOf("nopic.png") >0) {
ImgD.width="260";
} else {
if(image.width>0 && image.height>0){
if(image.width/image.height>= FitWidth/FitHeight){
if(image.width>FitWidth){
ImgD.width=FitWidth;
ImgD.height=(image.height*FitWidth)/image.width;
}else{
ImgD.width=image.width;
ImgD.height=image.height;
}
} else{
if(image.height>FitHeight){
ImgD.height=FitHeight;
ImgD.width=(image.width*FitHeight)/image.height;
}else{
ImgD.width=image.width;
ImgD.height=image.height;
}
}
}
}
}
在image的
onload='javascript:DrawImage(this,300,300)'里面执行这个js函数