0

我想知道当我向下滚动时是否有机会在屏幕上仍然有一个固定的标题,我该怎么做?

我试图position: fixed;.header.dark类中添加 CSS,但它破坏了模板。

谢谢你的帮助。

4

2 回答 2

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/

于 2014-02-20T21:32:49.363 回答
0

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

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

CSS

.header {
    position:fixed;
    width:100%;
    top:0;
    left:0;
    background:blue;
    z-index:999;
}
于 2014-02-20T21:07:29.287 回答