Tricky CSS Questions

This CSS quiz is for people who think they know CSS well. It covers the behaviors that surprise even experienced developers: stacking contexts, margin collapsing through parents, percentage padding, :is() specificity, sticky elements that will not stick and flex items that will not shrink.

Schwer 10 Fragen ~8 Minuten Bestanden ab 80%

Modus wählen

Du spielst als Gast: Melde dich an, damit XP und Serie gespeichert werden.

Beispielfrage

Frage 1 von 10

.child and .b overlap. Which one is drawn on top?

<style>
  .a { position: relative; z-index: 1; }
  .child { position: relative; z-index: 9999; }
  .b { position: relative; z-index: 2; }
</style>
<div class="a"><div class="child">child</div></div>
<div class="b">b</div>
Lösung zeigen

D. .b, because .child is trapped inside .a's stacking context .a with position and z-index creates a stacking context, and .child's 9999 only counts inside it. At the outer level .a (1) is compared with .b (2), so .b and everything in it wins.

Darum geht es in diesem Quiz

  • Stacking contexts and why z-index: 9999 can lose
  • Margins that escape their parent and percentage padding
  • Specificity of :is() and exact attribute selectors
  • position: sticky and position: fixed surprises
  • Inline-block whitespace, 100vh on mobile and flex min-width

Häufige Fragen

Brauche ich ein Konto?

Nein. Jeder kann spielen. Mit Anmeldung werden XP, Serie, Abzeichen und Verlauf gespeichert.

Kann ich es wiederholen?

Ja. Dein Bestwert bleibt erhalten, und Fragen und Antworten werden jedes Mal neu gemischt.