2013-09-21 30 views
-1

對不起,如果我的曲調不好!我使用這個HTML代碼Div應該只保留固定在特定格

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

你還沒有關閉外部div元素。