什么是最好的方法做一个固定的顶部不重叠的顶部? [英] What's the best way to do a fixed topbar that doesn't overlap the top?

查看:78
本文介绍了什么是最好的方法做一个固定的顶部不重叠的顶部?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

例如,stackoverflow有一个新成员的顶栏。

For instance stackoverflow has a topbar for new members. The topbar is fixed and pushes down the page without overlapping the top of the page.

这是如何实现的?

Javascript?

Javascript? Or can this be done with just css?

推荐答案

你可以这样做,创建一个固定的标题:

You could do something like this to create a fixed header:

<style>
body { margin: 0; }
div.header { position: fixed; height: 50px; width: 100%; }
div.content { padding-top: 50px; }
</style>

<body>
<div class="header">header</div>
<div class="content">content</div>
</body>

也许可以查看ie5.5 / ie6.0修复: http://www.howtocreate.co.uk/fixedPosition.html

Maybe check out the ie5.5 / ie6.0 fix here: http://www.howtocreate.co.uk/fixedPosition.html

这篇关于什么是最好的方法做一个固定的顶部不重叠的顶部?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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