将文档末尾的元素放在页面顶部 [英] Position an element from the end of the document at the top of the page
本文介绍了将文档末尾的元素放在页面顶部的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在文档的< / body>
标签之前有一个 div
)。
我想使用CSS或JavaScript在页面顶部显示这个div。
I have a div
just before the </body>
tag of the document (before the document ends).
And I want to display this div on the top of the page using CSS or JavaScript.
我知道 position:absolute;
。问题是,如果我使用它,div将显示在位于顶部,而不是在此内容之前的其他内容的顶部。
I know about position:absolute;
. The problem is that if I use it, the div will show on top of other content that's located in the top, not before this content.
因此,有任何其他方式
推荐答案
您可以对div元素使用 position:absolute margin-top 到body元素,等于div的可能高度。
You can use position:absolute for the div element and then assign a margin-top to body element which equals the possible height of the div.
这篇关于将文档末尾的元素放在页面顶部的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文