代码拉取完成,页面将自动刷新
同步操作将从 惟忆代码/picfixed 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
/****/
(function($) {
var _setting={
paddingTop:0,paddingLeft:0,paddingRight:0,paddingBottom:0,
borderTop:0,borderLeft:0,borderRight:0,borderBottom:0,
borderStyle:"dotted"
};
$.fn.fixedpicSet = function(config){
for(var i in config){
_setting[i]=config[i];
}
return this;
}
$.fn.fixedpicDiv=function(){
//给那些没有宽度的DIV根据里面的图片加div
}
function _fixsize(obj,height,width,lineWidth){
var children=obj.children();
var len = children.length;
var staticWidth = (_setting.paddingRight+_setting.paddingLeft+_setting.borderLeft+_setting.borderRight)*len;//边距不参与变化,这部一直不变
var percent = (width-staticWidth)/(lineWidth-staticWidth);//参与的缩放比例
children.css({"float":"left",
"padding-top":_setting.paddingTop+'px',
"padding-left":_setting.paddingLeft+'px',
"padding-bottom":_setting.paddingBottom+'px',
"padding-right":_setting.paddingRight+'px',
"border-width":_setting.borderTop+'px '+_setting.borderRight+'px '+_setting.borderBottom+'px '+_setting.borderLeft+'px',
"border-style":_setting.borderStyle
});
var lastHeight = Math.round(height*percent)+_setting.paddingBottom+_setting.paddingTop+_setting.borderTop+_setting.borderBottom;
var lastBoxWidth = width-staticWidth;
children.each(function(index,em){
var emObj = $(em);
emObj.height(lastHeight);
if(index == len-1){
emObj.width(lastBoxWidth);
}else{
var boxWidth = Math.round(emObj.width()*percent);
lastBoxWidth=lastBoxWidth-boxWidth;
emObj.width(boxWidth);
}
});
}
$.fn.fixedpic = function(height,width) {
_self = this;
width = width || this.width();
height = height||300;
var children = this.children();
len = children.length;
var lineWidth = 0;
var aline = $('<div></div>').width(width);
children.each(function(index,em){
var emObj = $(em);
var percent = emObj.width()/emObj.height();
var fixWidth = Math.round(percent*height) ; //保持比例
aline.append(emObj.clone().width(fixWidth));
emObj.remove();
lineWidth += fixWidth+_setting.paddingLeft+_setting.paddingRight+_setting.borderLeft+_setting.borderRight;
if(lineWidth>width){
_fixsize(aline,height,width,lineWidth)
_self.append(aline.clone());
aline.empty();
trueWidth = 0;
lineWidth= 0;
}else if(index == len-1){
_self.append(aline.clone());
aline.empty();
}
})
};
})(jQuery)
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。