用JS重新定位div

时间:2012-08-16 10:18:57

标签: javascript html

有没有办法使用JS重新定位div,以便在页面中的HTML中获得最相关的副本。但是,当涉及最终用户看到的内容时,可以灵活地在任何地方显示相同的副本?即...

HTML:

<div id="three">Three(to be at the top of HTML but display at bottom in browser)</div>
<div id="one">One</div>
<div id="two">Two</div>

浏览器:

One
Two 
Three(to be at the top of HTML but display at bottom in browser)

是否有任何教程,我需要使用什么功能?感谢。

2 个答案:

答案 0 :(得分:0)

在CSS中写这个,不需要JS:

#three {
    position: fixed;
    bottom: 0;
}

答案 1 :(得分:0)

您可以使用此类javascript来修改CSS属性。为了与名为Safari的用户一样,我们可以提出这样的代码:

<script>
  document.getElementById('three').style.position = 'fixed';
  document.getElementById('three').style.bottom = 0;
</script>
相关问题