<script type="text/javascript">
var setNewsImg = function(obj){
$(obj).find('img').each(function(i){
var imgw = $(this).width();
var imgh = $(this).height();
var scale=1;
if(imgw>634){
scale = 634/imgw;
console.log(scale);
$(this).height(scale*imgh);
$(this).width(scale*imgw);
}
});
}
</script type="text/javascripy">
调用
<script>
$(function(){
setNewsImg('.news-img')
})
</script>
$(window).bind("load", function() {
// 图片修改大小
$('#imglist img').each(function() {
var maxWidth = 120; //初始化最大显示宽度
var maxHeight = 120; //初始化最大显示高度
var ratio = 0;
var width = $(this).width();
var height = $(this).height();
if(width > maxWidth){
ratio = maxWidth / width;
$(this).css("width", maxWidth);
$(this).css("height", height * ratio);
height = height * ratio;
}
if(height > maxHeight){
ratio = maxHeight / height;
$(this).css("height", maxHeight);
$(this).css("width", width * ratio);
width = width * ratio;
}
});
});
<script>
$(function(){
$(".daima img").each(function(){
maxWidth =700;
ratio = 0;
width = $(this).width();
height = $(this).height();
if(width > maxWidth){
ratio = maxWidth / width;
$(this).width(maxWidth);
height = height * ratio;
$(this).height(parseInt(height));
}});
});
</script>
$('#content').find('img').each(function(){
var img = this;
if (img.width > 600) {
img.style.width = "600px";
img.style.height = "auto";
//$(img).removeAttr('height');
var aTag = document.createElement('a');
aTag.href = img.src;
aTag.target="_blank";
$(aTag).addClass('bPic')
.insertAfter(img).append(img)
.lightBox(options);
}
});
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有