我想知道当我向下滚动的时候,我是否可以在屏幕上看到一个固定的标题,我该怎么做?
我试图添加到.header.dark类中的CSS position: fixed;,但它破坏了模板。
谢谢你的帮助。
发布于 2014-02-21 05:07:29
应该可以正常工作。试试这个:
<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-21 05:32:49
尝试用空格分隔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/
https://stackoverflow.com/questions/21916658
复制相似问题