有没有办法使用JavaScript在html跨度上强加顶部和左侧属性值?

时间:2013-05-25 00:39:04

标签: html dom

信息量很大的S.O.问题

"http://stackoverflow.com/questions/288699/get-the-position-of-a-div-span-tag" 

注意找到位置的方法,但是如果 top left 是span元素的“无效属性*”,那么如何将它定位到像素,exactimento!一个人想要的地方?

1 个答案:

答案 0 :(得分:0)

html css使用的定位是: 静态的 固定 相对的 绝对 如果位置是相对的,绝对的或固定的,则可以使用顶部右下和左下.. 例如:

<div id="main">
<span id="pos_fixed"></span>
</div>
then you can have:
#main  {
position:relative;
}
span#pos_fixed
{
position:fixed;
top:30px;
right:5px;
}

但如果它们是静态的,这些都不会起作用。 您可以阅读更多信息:http://webdesign.about.com/od/advancedcss/a/aa061307.htm