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.

ยาก 10 ข้อ ~8 นาที ผ่านที่ 80%

เลือกโหมด

กำลังเล่นแบบผู้เยี่ยมชม: เข้าสู่ระบบเพื่อเก็บ XP และ streak

ตัวอย่างคำถาม

ข้อ 1 จาก 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>
ดูเฉลย

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.

ควิซนี้มีเนื้อหาอะไรบ้าง

  • 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

คำถามที่พบบ่อย

ต้องมีบัญชีไหม?

ไม่ต้อง ใครก็เล่นได้ เข้าสู่ระบบเพื่อเก็บ XP, streak, เหรียญตรา และประวัติ

ทำซ้ำได้ไหม?

ได้ ระบบเก็บคะแนนที่ดีที่สุดไว้ และสลับคำถามกับตัวเลือกใหม่ทุกครั้ง