我想知道当我向下滚动时是否有机会在屏幕上仍然有一个固定的标题,我该怎么做?
我试图position: fixed;
在.header.dark
类中添加 CSS,但它破坏了模板。
谢谢你的帮助。
我想知道当我向下滚动时是否有机会在屏幕上仍然有一个固定的标题,我该怎么做?
我试图position: fixed;
在.header.dark
类中添加 CSS,但它破坏了模板。
谢谢你的帮助。
尝试用空格分隔 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/
应该可以正常工作。尝试这个:
<div class="header">This is the header</div>
CSS
.header {
position:fixed;
width:100%;
top:0;
left:0;
background:blue;
z-index:999;
}