[英]Header position: fixed
我想知道在向下滾動時是否可以在屏幕上仍然顯示固定的標題,該怎么辦?
我試圖添加到CSS position: fixed;
在.header.dark
類中,但它破壞了模板。
謝謝你的幫助。
應該工作正常。 嘗試這個:
<div class="header">This is the header</div>
的CSS
.header {
position:fixed;
width:100%;
top:0;
left:0;
background:blue;
z-index:999;
}
嘗試用空格分隔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/
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.