在滚动页面时,如何使div保持在其他div的顶部?

-1 html css scroll

请帮助我.我试过了.

这是我目前的代码

HTML

    <div id="header"><!--beggining of header-->

    </div><!--end of header-->
Run Code Online (Sandbox Code Playgroud)

CSS

    #header {
    width: auto;
    height: 100px;
    background-color: #F0F;
    border-bottom-style: solid;
    border-bottom-color: #000;
    position: fixed;
    }
Run Code Online (Sandbox Code Playgroud)

抱歉.这是我第一次使用这个STE.我不能发布代码.但在这里看到完整的HTML

wan*_*kaf 5

检查这个小提琴

HTML:

<div class="cover">
  top
   <div class="fixed-box">
     hello                            
   </div>
</div>
Run Code Online (Sandbox Code Playgroud)

CSS:

.fixed-box {
  width:100px;/*just for preview*/
  height:100px;/*just for preview*/
  background:red;/*just for preview*/
  position:fixed;
  top:10px;
}
.cover {
  width:500px;/*just for preview*/
  height:10000px;/*just for preview*/
  background:blue;/*just for preview*/
}
Run Code Online (Sandbox Code Playgroud)