Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The newly added element blinks #319

Open
rmstsd opened this issue Nov 14, 2024 · 1 comment
Open

The newly added element blinks #319

rmstsd opened this issue Nov 14, 2024 · 1 comment

Comments

@rmstsd
Copy link

rmstsd commented Nov 14, 2024

In this case, the newly added element blinks when the button is clicked.

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>tt</title>

    <style>
      .widget-name h2 {
        font-size: 12px;
      }

      .widget-name[min-width~='400px'] h2 {
        font-size: 18px;
      }

      .widget-name[min-width~='600px'] h2 {
        padding: 55px;
        text-align: center;
        font-size: 24px;
      }

      .widget-name[min-width~='700px'] h2 {
        font-size: 34px;
        color: red;
      }
    </style>

    <script src="./ResizeSensor.js"></script>
    <script src="./ElementQueries.js"></script>
  </head>

  <body>
    <button>click</button>
  
    <div class="container"></div>

    <script>
      document.querySelector('button').addEventListener('click', function () {
        const innerHTML = `
          <div class="widget-name">
            <h2>Element responsiveness FTW!</h2>
          </div>
        `

        document.querySelector('.container').innerHTML = innerHTML
      })
    </script>
  </body>
</html>
20241114-164216.mp4
@rmstsd
Copy link
Author

rmstsd commented Nov 14, 2024

Is it okay to use MutationObserver for the body to listen for additions to the dom? @marcj

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant