A position: fixed box with z-index: auto paints above later positioned siblings

Open
#1,493 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
47/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
css, html, rust
Domain
frontend, web-dev

Research direction

Start by reading the painting and stacking-order code, then inspect how fixed descendants with z-index: auto are grouped relative to positioned ancestors. The issue names no source files or tests, so locate the relevant rendering entry points and existing coverage. Done when the reproduction paints the blue box above the red fixed layer, matching the stated browser behavior.

Written by the indexing model from the issue text.

Description

A-Paint C-Bug

A position: fixed box with z-index: auto inside a positioned ancestor is painted after (above) that ancestor's later positioned descendants. By CSS 2.1 Appendix E, step 8, positioned descendants with z-index: auto paint in tree order, so the fixed box should be painted first, underneath.

<body style="margin:0">
  <div style="position:relative; height:200px">
    <div style="position:fixed; inset:0; background:rgba(255,0,0,.5)"></div>
    <div style="position:relative; margin:20px; height:100px; background:blue"></div>
  </div>
</body>

Expected (Chrome, Firefox, WebKit): the blue box is drawn on top of the translucent red layer.
Actual: the red layer is drawn over the blue box.

The fixed box is hoisted to its containing block (the viewport) and painted in the root's positioned layer after the whole relative ancestor. That ancestor paints its own positioned descendants as one unit, so the fixed box ends up above all of them. #1421 fixes the z-indexed case. This is the z-index: auto one, which is common for a full-screen decorative backdrop placed first in an app shell.

Workaround: position: absolute; inset: 0 when the ancestor fills the viewport.

Dominant language
Rust
Stars
4.5k
Forks
281
Avg merge
6h 6m
Merged PRs (30d)
184

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from DioxusLabs/blitz

All issues in DioxusLabs/blitz

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.