Skip to content

Width of <span> element is wrong #484

Description

@IceLeach

Describe it simply:

Using a span element with display: block and set width and height.
The width well be incorrect.

  1. Width will be 100%.
Image
  1. When in a flexbox, width will depend on children.
Image

When span element has no children, these issues do not exist.

Quick demo to reproduce

<!doctype html>
<html>
  <head>
    <script src="https://unpkg.com/@zumer/snapdom@2.24.0/dist/snapdom.js"></script>
    <style>
      * {
        box-sizing: border-box;
      }

      .item {
        display: flex;
      }

      .tag {
        display: block;
        width: 16px;
        height: 16px;
        font-size: 10px;
        line-height: 16px;
        color: #d95350;
        border: 1px solid #d95350;
        border-radius: 4px;
        text-align: center;
      }

      #button {
        display: block;
        margin: 24px 0;
      }
    </style>
  </head>
  <body>
    <div id="element">
      <!-- case 1 -->
      <span class="tag">T</span>
      <!-- case 2 -->
      <div class="item">
        <span class="tag">T</span>
      </div>
    </div>
    <button id="button">Capture</button>
    <script>
      const capture = async () => {
        const img = await snapdom.toPng(document.querySelector("#element"));
        document.body.appendChild(img);
      };
      document.querySelector("#button").addEventListener("click", capture);
    </script>
  </body>
</html>

Anything else we should know?

snapdom: 2.24.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working🔧 in developmentThis issue is being actively worked on

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions