今天又‘2’了,写了居中问题,居然把参数传错了,找了好久,测试了好久都没找出来,在此感谢我的partner的灵机一动。
KISSY.add('app/login',function(S){
function init(obj){
center(obj);
$(window).resize(function(){
center(obj);
});
$(window).scroll(function(){
center(obj);
});
}
function center(obj){
var winWidth = $(window).width();
var winHeight = $(window).height();
var scrolltop = $(document).scrollTop();
var width = obj.width();
var height = obj.height();
var objLeft = (winWidth - width)/2;
var objTop = (winHeight - height)/2 + scrolltop;
obj.css({left: objLeft + 'px', top: objTop + 'px'});
}
PW.namespace('login');
PW.login = init;
},{requires:['thirdparty/jquery']})
在使用KISSY.js库处理居中问题时,作者分享了遇到的挑战、解决方案及合作伙伴的灵感瞬间,强调了避免常见错误的重要性。
242

被折叠的 条评论
为什么被折叠?



