标题位置:固定

时间:2014-02-20 18:38:40

标签: html css header fixed-header-tables

我想知道,当我向下滚动时,我是否仍然可以在屏幕上显示固定的标题,我该怎么办呢?

我尝试添加到position: fixed;类中的CSS .header.dark,但它正在打破模板。

感谢您的帮助。

2 个答案:

答案 0 :(得分:0)

应该可以正常工作。试试这个:

<div class="header">This is the header</div>

CSS

.header {
    position:fixed;
    width:100%;
    top:0;
    left:0;
    background:blue;
    z-index:999;
}

答案 1 :(得分:0)

尝试用空格分隔css代码中的两个类。由此:

.header.dark {
//fixed position
}

对此:

.header .dark {
// fixed position
}

我不知道你的代码是什么样的,但如果你正在尝试做这样的事情

<h1 class="three four">Double Class</h1>

然后你的css看起来像这样

.three.four { color: red; }

但如果你想做这样的事情

<div class="header">
<div class="dark">Stay at top</div>
</div>

然后你的css看起来像这样

.header .dark { position:fixed; }

这是一个很好的参考:http://css-tricks.com/multiple-class-id-selectors/

相关问题