Ich habe folgende HTML:Position absolut div in einem Überlauf-y: blättern div
<div class="container">
<div class="scrollable-block">
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
<div class="absolute-div"></div>
</div>
und CSS:
.container {
width: 200px;
height: 300px;
background: green;
}
.scrollable-block {
width: 200px;
max-height: 250px;
overflow: scroll;
position: relative;
}
.absolute-div {
width: 20px;
height: 20px;
background: purple;
position: absolute;
top: 0;
right: -10px;
}
Und hier ist eine Live-Demo: http://jsfiddle.net/BYTam/1/
Das grüne div ist der Container und hat eine feste Breite. Das gelbe div ist darin und hat maximale Höhe und Überlauf-y: scroll. Es soll die gleiche Breite wie die grüne haben. Ich versuche das lila div absolut zu positionieren, relativ zum gelben div, aber außerhalb des grünen div - Grund dafür ist, dass ich nicht möchte, dass das gelbe div eine horizontale scrollbar hat. Ist das überhaupt möglich?
Vielen Dank!
Vielleicht können Sie Position: relativ auf .container statt auf .scrollable-Block? Ist das okay für dich? –
Nein, es muss leider relativ zum .scrollable-Block sein. Dies ist ein minimiertes Beispiel für eine komplexere Struktur, die sich so verhalten muss. –