当前位置: 首页 > news >正文

上海装修做网站的倒闭了佛山网站定制

上海装修做网站的倒闭了,佛山网站定制,沂南做网站,网站的策划做推广//获取元素在包含元素框中的大小 //第1个函数为获取元素在包含元素中左内边框的距离 function getELementLeft(element){//获取元素在包含元素左边距离var actualeftelement.offsetLeft;//获取元素的上级包含元素var currentelement.offsetParent;//循环到一直没有包含元素whil…
//获取元素在包含元素框中的大小
//第1个函数为获取元素在包含元素中左内边框的距离
function getELementLeft(element){//获取元素在包含元素左边距离var actualeft=element.offsetLeft;//获取元素的上级包含元素var current=element.offsetParent;//循环到一直没有包含元素while(current !==null){actualeft+=current.offsetLeft;current=current.offsetParent;}return actualeft;}
//第2个函数为获取元素在包含元素中顶部内边框的距离function getElementTop(element){var actuatop=element.offsetTop;var current=element.offsetParent;while(current !==null){actuatop += current.offsetTop;current=current.offsetParent;}return actuatop;}//获取元素在浏览器工作区域中的位置,相对于浏览器工作区域的左、右、上、下的值
function getBoundingClientRect(element){//获取带有垂直滚动条的页面区,包括在上面的隐藏内容的像素数,document.body.scrollTop为兼容IEvar scrollTop=document.documentElement.scrollTop || document.body.scrollTop;//获取带有水平滚动条的页面区,包括在左边的隐藏内容的像素数,document.body.scrollLeft为兼容IEvar scrollLeft=document.documentElement.scrollLeft || document.body.scrollLeft;//检查元素的getBoundingClientRect方法,这个方法是元素自有的,不是我们上面的那个函数名if(element.getBoundingClientRect){//设置arguments.callee的offset属性,才设置肯定为NaN,不等于numberif(typeof arguments.callee.offset !="number"){//创建一个零时的div元素,设置他的left top 为0var temp=document.createElement("div");temp.style.cssText="position:absolute;left:0;top:0;";document.body.appendChild(temp);//让offset获取到值,如果是IE8浏览器以前的为-2arguments.callee.offset=-temp.getBoundingClientRect().top-scrollTop;document.body.removeChild(temp);temp=null;}var rect=element.getBoundingClientRect();//获取offset值var offset=arguments.callee.offset;//返回元素对于浏览器工作区左中上下距离return {left:rect.left + offset,right:rect.right+offset,top:rect.top+offset,bottom:rect.bottom+offset};//如果元素没有element.getBoundingClientRect,则以我们上面两个函数来计算带滚动条的工作区坐标位置}else{var actualLeft=getElementLeft(element);var actualTop=getElementTop(element);}return {left:actualLeft-scrollLeft,right:actualLeft+element.offsetWidth - scrollLeft,top:actulTop-scrollTop,bottom:actualTop+element.offsetHeight - scrollTop}            }
var div=document.getElementById("container");
var bd=document.getElementsByClassName("bd")[0];
var size=getBoundingClientRect(bd);
console.log(size.left);

//html代码部分

<div id="container"><div class="bd"></div></div>

//css

<style type="text/css">#container{width: 800px;height: 500px;border: 1px solid #ccc;margin: 0 atuo;margin-top: 50px;}div#container .bd{width:400px;height: 400px;border: solid 1px blue;position: relative;top: 50px;left:100px;}</style>
http://www.ds6.com.cn/news/36891.html

相关文章:

  • 有关天猫网站开发的论文奶茶网络营销策划方案
  • 吉林省绥中县城乡建设局网站公司怎么建立自己的网站
  • 做网站原型现成的框架免费seo提交工具
  • wordpress增加边栏宁波seo外包服务
  • 网站设计就业培训学校排名黄山seo公司
  • 建设厅考试网站全球搜索引擎排名2021
  • 邢台做网站推广的地方朝阳区seo技术
  • 武汉网站建站搜索引擎优化的名词解释
  • 网站原型怎么做百度竞价系统
  • 网站前后台模板广州最新消息
  • cms做的电影网站昆明排名优化
  • iphone开发网站网站关键词seo排名
  • 盐城网站优化方案哪个平台做推广效果好
  • 建设信息网站聚合广告联盟
  • 做的很酷炫的网站网站seo具体怎么做?
  • 怎么做国际网站seo赚钱方法大揭秘
  • 网站字体企业中层管理人员培训课程
  • 培训网站排名手机百度网页版 入口
  • 国内手机网站建设站长工具pr值查询
  • 网页美工设计师seozhun
  • 昆明高端网站建设公司郑州网站公司哪家好
  • 江西建设三类人员网站网站运营优化培训
  • 企业建网站解决方案东莞市网络seo推广服务机构
  • 随州网站建设哪家好培训体系包括四大体系
  • 济南市商务局官方网站百度推广教程视频教程
  • 自己公司怎么做网站网络营销策划书论文
  • jq效果较多的网站服务器租用
  • 模板网站建设优惠公司网站制作流程
  • 网站做支付需要准备什么条件百度的广告
  • 在线作图免费网站杭州小周seo