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.

Khó 10 câu hỏi ~8 phút Đạt từ 80%

Chọn chế độ

Bạn đang chơi với tư cách khách: đăng nhập để lưu XP và streak.

Câu hỏi mẫu

Câu 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>
Xem đáp án

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.

Quiz này có gì

  • 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

Câu hỏi thường gặp

Có cần tài khoản không?

Không. Ai cũng chơi được. Đăng nhập để lưu XP, streak, badge và lịch sử.

Có làm lại được không?

Được. Điểm cao nhất của bạn được giữ lại, câu hỏi và đáp án được xáo trộn mỗi lần.