kiln-app 0.1.0

Native desktop apps from real HTML, CSS and TypeScript, rendered without Chromium or a WebView
<!doctype html>
<html>
  <head>
    <meta charset="utf-8" />
    <title>Kiln — position: fixed</title>
    <style>
      body {
        margin: 0;
        background: #0b1226;
        color: #f4e7d3;
        font-family: Menlo, monospace;
        font-size: 12px;
      }
      h1 {
        margin: 0;
        padding: 20px 24px 0;
        font-family: Helvetica, Arial, sans-serif;
        font-size: 13px;
        letter-spacing: 0.18em;
        text-transform: uppercase;
        color: #8fa0c4;
      }
      .ancestor {
        position: relative;
        left: 200px;
        top: 150px;
        width: 300px;
        height: 200px;
        border: 1px dashed #22315c;
      }
      .fixed {
        position: fixed;
        width: 150px;
        height: 40px;
        padding: 6px;
        border-radius: 6px;
      }
      #free {
        top: 60px;
        left: 24px;
        background: #7fc3ac;
        color: #0b1226;
      }
      #nested {
        top: 60px;
        left: 400px;
        background: #f5a93c;
        color: #0b1226;
      }
      #stretch {
        position: fixed;
        inset: 0;
        border: 2px solid #f5a93c;
      }
    </style>
  </head>
  <body>
    <h1>position: fixed</h1>

    <div class="fixed" id="free">no positioned ancestor</div>

    <div class="ancestor">
      <div class="fixed" id="nested">inside position: relative</div>
      <div id="stretch"></div>
    </div>

    <script>
      const check = (id, want) => {
        const r = document.querySelector("#" + id).getBoundingClientRect();
        const got =
          Math.round(r.x) +
          "," +
          Math.round(r.y) +
          " " +
          Math.round(r.width) +
          "x" +
          Math.round(r.height);
        console.log(
          (got === want ? "ok    " : "WRONG ") +
            id.padEnd(8) +
            " got " +
            got.padEnd(18) +
            " want " +
            want,
        );
      };

      console.log("viewport 1000x700");
      check("free", "24,60 162x52");
      check("nested", "400,60 162x52");
      check("stretch", "0,0 1000x700");
    </script>
  </body>
</html>