Skip to content

Negative z-index is not rendered correcly

See following example:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>z-index-4.html</title>
    <style>
        @page {
            size: 400pt 400pt;
            margin: 100pt;
        }

        html {
            font-size: 8pt;
            line-height: 10pt;
            margin: 100pt;
        }

        #lvl_0 {
            width: 120pt;
            height: 120pt;
            position: relative;
            background: rgba(255, 0, 0, .8);
        }
        #lvl_1 {
            width: 100pt;
            height: 100pt;
            position: relative;
            z-index: auto;
            background: rgba(0, 255, 0, .5);
            left:-40pt;
            top: -60pt;
        }
        #lvl-1 {
            width: 50pt;
            height: 50pt;
            position: relative;
            background: rgba(0, 0, 255, .5);
            right:-80pt;
            top: 0;
            z-index: -1;
        }
        #lvl-2 {
            width: 50pt;
            height: 50pt;
            position: relative;
            background: rgba(200, 0, 200, 1);
            right:-80pt;
            bottom: 20pt;
            z-index: -2;
        }

    </style>
</head>
<body>
    <div id="lvl_0">
        <div id="lvl_1">
            <div id="lvl-1"></div>
            <div id="lvl-2"></div>
        </div>
    </div>
</body>
</html>
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information