by Anonymous » 12 Apr 2025, 23:05
Es gibt ein Container -Div, das horizontal überfüllt (scrollen), basierend auf dynamischen Inhalten.
Ich möchte ein Div in ihn setzen, das die gesamte Breite des Behälters füllt. Mit der CSS-Eigenschaftsbreite: 100%< /code> funktioniert hier nicht, da es den Überlauf nicht berücksichtigt. PrettyPrint-Override ">.overflowing-container {
overflow-x: auto
}
.unknown-width {
width: 130%; /* this is unknown, determined by content */
background-color: yellow;
padding: 20px;
}
.too-narrow {
width: 100%;
background-color: lightblue;
padding: 20px;
}< /code>
This div is of unknown width. It makes the parent overflow.
This div should fill its overflowing parent, but "width: 100%" is only the viewport width in this context. When you scroll to the right, this stops.
< /code>
< /div>
< /div>
< /p>
Gibt es eine Lösung, die nur CSS verwendet? Oder muss ich JavaScript verwenden, um die übergeordnete Breite abzufragen?
Es gibt ein Container -Div, das horizontal überfüllt (scrollen), basierend auf dynamischen Inhalten. [url=viewtopic.php?t=14917]Ich möchte[/url] ein Div in ihn setzen, das die gesamte Breite des Behälters füllt. Mit der CSS-Eigenschaftsbreite: 100%< /code> funktioniert hier nicht, da es den Überlauf nicht berücksichtigt. PrettyPrint-Override ">.overflowing-container {
overflow-x: auto
}
.unknown-width {
width: 130%; /* this is unknown, determined by content */
background-color: yellow;
padding: 20px;
}
.too-narrow {
width: 100%;
background-color: lightblue;
padding: 20px;
}< /code>
This div is of unknown width. It makes the parent overflow.
This div should fill its overflowing parent, but "width: 100%" is only the viewport width in this context. When you scroll to the right, this stops.
< /code>
< /div>
< /div>
< /p>
Gibt es eine Lösung, die nur CSS verwendet? Oder muss ich JavaScript verwenden, um die übergeordnete Breite abzufragen?