Div应仅在特定div中保持固定

时间:2013-09-21 13:11:18

标签: css html fixed

对不起,如果我的曲调不好!我正在使用此HTML代码

HTML:

<div style="width:300px; height:300px; background-color:blue; overflow:scroll">
   <div style="width:100px; height:100px; background-color:red; position:fixed"></div>
</div>

CSS:

  .outer {
    width:200px;
    height:600px;
    background-color:red;
    margin:0 auto;
}
.inner {
    width:50px;
    border:1px solid white;
    position:fixed; margin-left:150px
}

问题:我的问题是,内部div应该在外部div中保持固定。当我向下滚动页面时,内部div应该保持固定,但是当外部div和页面转到下一个div时,固定div也应该与外部div一起移动。它不应该在其他div中保持固定。

1 个答案:

答案 0 :(得分:1)

你还没有关闭外部div元素。