使用css3列 - 如何可以获得元素位置? [英] using css3 columns - how can get element position?

查看:124
本文介绍了使用css3列 - 如何可以获得元素位置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

要将长html文件与列分开,我使用css3列。

To divide the long html file with the columns, I used css3 columns.

padding: 0px
height: 1024px
-webkit-column-gap: 0px
-webkit-column-width: 768px

我想要获得指定元素的位置,所以我使用下面的JavaScript代码。

And i wanted to get the position of the specified element, so i used the following javascript code.

function getPos(el) {
   for( var lx=0, ly=0; el!=null; lx+=el.offsetLeft, ly+=el.offsetTop, el=el.offsetParent);
         return {x:lx, y:ly};
}



我认为y值的范围是0到height:1024px,但是该值超过1024,x值在0到column-width:768的范围内。

I thought that the y value is in range of 0 to height:1024px, but that value exceeds 1024 and x value is in range of 0 to column-width:768.

如何从第一个左上角位置获取实际位置是在0到1024,x是一些值?

How can i get the realative position from the first top left position which y is in 0 to 1024 and x is some value?

对不起,我的英语不好。

I'm sorry for my poor english.

谢谢。

推荐答案

jQuery方法 position 。是否可以包含jQuery?

The jQuery method position returns the correct answer for this. Is it possible for you to include jQuery?

请参阅 http ://jsfiddle.net/chris5marsh/GM2kp/ 为例。

这篇关于使用css3列 - 如何可以获得元素位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆