【发布时间】:2021-04-05 17:14:03
【问题描述】:
我已经尝试了类似线程中的几乎所有答案,但可以找到适合我的任何答案。
我有以下网站:
- 一个标题(div 跨越整个宽度)。
- 左列。
- 右栏。
标题和右列是固定的。
我希望左栏中的文本在滚动时消失在标题下方。
就像我在许多网站上看到的那样,带有消息的标题(例如“接受 cookie”)停留在固定位置。
有什么想法吗?
【问题讨论】:
我已经尝试了类似线程中的几乎所有答案,但可以找到适合我的任何答案。
我有以下网站:
标题和右列是固定的。
我希望左栏中的文本在滚动时消失在标题下方。
就像我在许多网站上看到的那样,带有消息的标题(例如“接受 cookie”)停留在固定位置。
有什么想法吗?
【问题讨论】:
HTML:
<div id="head">
<!-- here is the code of our header -->
</div>
<div id="content">
<!-- The next block for example with the main content -->
</div>
CSS:
#head{
width: 1000px;
height: 60px;
position: fixed;
background: #fff;
z-index: 1000;
}
/* So that our next block does not run under the header, as soon as the page is loaded, add an indent. */
#content {
margin-top: 60px;
}
【讨论】:
现在一切正常。
带有固定标题的左栏滚动:
.header {
overflow: hidden;
background-color: black;
position: fixed;
top: 0;
width: 100%;
}
右栏固定(响应式):
@media (min-width: 1200px) {
.rightcolumn {position: fixed;}
}
【讨论】: