简体   繁体   English

如何使用CSS在顶部显示最后一个div?

[英]How to display last div at top using CSS?

I have 4 different divs. 我有4个不同的div。 The last one is footer. 最后一个是页脚。 How can I put the last div at top using CSS? 如何使用CSS将最后一个div放在顶部?

The last one is the footer but you want to put it at the top ? 最后一个是页脚,但您想将其放在顶部吗? I'm not sur what you want to do ^^ 我不是你想做什么^^

With JS you could achieve it without doubt. 使用JS,您可以毫无疑问地实现它。

Maybe could you explain a little bit your situation :-) and when do you want to put the last one to footer (after page is loaded ?) 也许您可以解释一下您的情况:-),以及何时要将最后一个放在页脚(在页面加载后?)

But with this it should work : 但这应该可以工作:

.class1 { position:absolute; top:0; left:0; }

But be sure that your class1 is wraped in another class2 which contains : 但请确保将您的class1包装在另一个class2中,其中包含:

.class2 { position:relative; }

try this: 尝试这个:

<div id = "FooterAtTop">what ever here</div>

put this in CSS file or in <style> in head: 将其放在CSS文件中或<style>中:

#FooterAtTop

{
position: absolute;
top:0px;
left:0px;
}

Though if you want to keep it floating do this: 尽管如果您想使其保持浮动,请执行以下操作:

#FooterAtTop
{
position: fixed;
top:0px;
left:0px;
}

Hope it helps. 希望能帮助到你。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM