2017-03-29 6 views
0

Ich habe ein Element container, die müssen bleiben statisch. Im Inneren liegt , die ich behoben werden muss, wenn container überläuft und ich darin scrollen.Feste div innerhalb scrollen statisch div

Beispiel:

<div id="container" style="width: 850px; height: 200px; position: static;"> 
    <div id="fix"></div> 
    <div id="otherStuff" style="width: 2000px;"></div> 
</div> 

Kann ich dies mit CSS?

+0

Können Sie bitte Ihre Frage näher erläutern? Es ist sehr verwirrend, was du willst – Lucian

Antwort

1

Sie können den Inhalt, der überlaufen soll, in ein Element mit overflow-x: scroll einfügen, und das Element #fix bleibt dort, wo es ist.

.overflow { 
 
    overflow-x: scroll; 
 
}
<div id="container" style="width: 850px; height: 200px; position: static;"> 
 
    <div id="fix">fix</div> 
 
    <div class="overflow"> 
 
    <div id="otherStuff" style="width: 2000px;">otherstuff</div> 
 
    </div> 
 
</div>