Gibt es eine einfache Möglichkeit, ein Element die Breite seiner Eltern zu füllen, wenn der Elternteil überfüllt ist?HTML

HTML-Programmierer
Anonymous
 Gibt es eine einfache Möglichkeit, ein Element die Breite seiner Eltern zu füllen, wenn der Elternteil überfüllt ist?

Post by Anonymous »

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?

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post