【问题标题】:Always-on-top header始终位于顶部的标题
【发布时间】:2010-12-07 18:44:17
【问题描述】:

我想像新的 twitter 一样添加一个始终位于顶部的标题。 说明:当用户向下滚动页面时,我希望标题保持在窗口顶部。

有人知道这样的脚本吗?或者可以针对我怎么做?

【问题讨论】:

    标签: javascript html css


    【解决方案1】:

    您可以使用位置:固定;在标题上。

    <div id="header">
    content goes here.
    </div>
    

    和 CSS:

    #header { position: fixed; z-index: 9999; top: 0; left: 0; }
    

    【讨论】:

      【解决方案2】:

      您需要将标题设置为fixed 以使其在整个页面中可见。并将top 值与width 一起适当设置。

      示例:

      #header{
        position:'fixed';
        top:0;
        width:800px;
      }
      

      【讨论】:

      • 需要注意的是,这种行为在 iPhone 版 Safari 上效果不佳。
      • @Jasper De Bruijn:我知道 IE6,想知道在使用 position fixed 时是否有解决方法。
      • 我不确定 IE6,因为我们的项目不再支持它。对于 iPhone 解决方案,请查看doctyper.com/archives/200808/fixed-positioning-on-mobile-safari
      【解决方案3】:

      在其 CSS 的标题上使用 position:fixed

      另外,不要忘记将lefttop 属性设置为您想要的位置:)

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-08-23
        相关资源
        最近更新 更多