offset

 

offsetParent(父级元素position是relative或absolute)

width/height(内容的宽高)

clientWidth=width+paddingleft+paddingright

clientHeight=height+paddingtop+paddingbottom

offsetWidth=width+paddingleft+paddingright+borderleft+borderright

offsetheight=height+paddingtop+paddingbottom+bordertop+borderbottom

offsetLeft=(offsetParent的padding-left)+(中间元素的offsetWidth)+(当前元素的margin-left)。

offsetTop=(offsetParent的padding-top)+(中间元素的offsetHeight)+(当前元素的margin-top)。

 

 

//jquery 对css的控制

$('#divid').css('propertyName') //get property value

$('#divid').css('propertyName','value') //set property value

$('#divid').offset().top  //相对于浏览器

$('#divid').offset().left

$('#divid').position().top  //相对于最近设置过position的元素

$('#divid').position().left

$('#divid').scrollTop(offset)  //返回或设置

$('#divid').height()  //content height

$('#divid').outerHeight()  //等于offsetheight   outerHeight(true)=offsetheight+margin

$(window).height()  //浏览器高度

$('#divid').css('cssText')   //var csstxt = $('#selector').css('cssText') + ';top:100;left:100;border:1px solid red;color:#f00;';$('#selector').css('cssText', csstxt);

posted @ 2015-08-23 22:23  fannet  阅读(204)  评论(0编辑  收藏  举报