网创优客建站品牌官网
为成都网站建设公司企业提供高品质网站建设
热线:028-86922220
成都专业网站建设公司

定制建站费用3500元

符合中小企业对网站设计、功能常规化式的企业展示型网站建设

成都品牌网站建设

品牌网站建设费用6000元

本套餐主要针对企业品牌型网站、中高端设计、前端互动体验...

成都商城网站建设

商城网站建设费用8000元

商城网站建设因基本功能的需求不同费用上面也有很大的差别...

成都微信网站建设

手机微信网站建站3000元

手机微信网站开发、微信官网、微信商城网站...

建站知识

当前位置:首页 > 建站知识

jquery图片自适应,设置图片自适应

jquery mobile 图片如何自动适应大小?

这位网友你好,你可以设置图片的宽度为100%就可以自适应大小了~

创新互联建站是一家专注于成都做网站、网站设计与策划设计,通榆网站建设哪家好?创新互联建站做网站,专注于网站建设10多年,网设计领域的专业建站公司;建站业务涵盖:通榆等地区。通榆做网站价格咨询:18982081108

jquery 如何让图片自适应大小

script type="text/javascript" src="js/jquery.min.js"/script

script type="text/javascript"

jQuery.fn.LoadImage=function(scaling,width,height,loadpic){

if(loadpic==null)loadpic="../img/loading.gif";

return this.each(function(){

var t=$(this);

var src=$(this).attr("src")

var img=new Image();

img.src=src;

//自动缩放图片

var autoScaling=function(){

if(scaling){

if(img.width0 img.height0){

if(img.width/img.height=width/height){

if(img.widthwidth){

t.width(width);

t.height((img.height*width)/img.width);

}else{

t.width(img.width);

t.height(img.height);

}

}

else{

if(img.heightheight){

t.height(height);

t.width((img.width*height)/img.height);

}else{

t.width(img.width);

t.height(img.height);

}

}

}

}

}

//处理ff下会自动读取缓存图片

if(img.complete){

autoScaling();

return;

}

$(this).attr("src","");

var loading=$("img alt=\"加载中...\" title=\"图片加载中...\" src=\""+loadpic+"\" /");

t.hide();

t.after(loading);

$(img).load(function(){

autoScaling();

loading.remove();

t.attr("src",this.src);

t.show();

});

} );

}

/script

div id="content"img src="img/20120518073933709.jpg"//div

script type="text/javascript"

!--

$(window).load(function(){

$('#content img').LoadImage(true, 600,500,'img/loading.gif');

});

//--

/script

CSS/Jquery图片自适应的几种方式

1,用HTML5技术

2,还是传统的HTML,但是可以做CSS,让图片宽度在电脑端和手机端自适应


名称栏目:jquery图片自适应,设置图片自适应
当前链接:http://bjjierui.cn/article/phiijh.html

其他资讯