css-element-queries
css-element-queries copied to clipboard
The newly added element blinks
trafficstars
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>
https://github.com/user-attachments/assets/3c938c08-06eb-403a-bf31-b3fc0254ef9f