I don't understand why media query don't work after I change the width of an HTML element with javascript . If for example an element has INITIALLY a width equal to 200px and then I change its width to 100px programmatically with javascript .So when I expect another change of this width due to media query , it does not work , in fact it keeps the last size made by javascript as illustrated below .
So can you explain to me why and can tackle this issue ?
// Embedded CSS : initial width
#main { width:48%}
let main = document.getElementById("main"); // html element
main.style.width="48%";
// css media query code which does not work due to javascript change
@media(max-width: 550px) {
#main { width:100%}
}
NB: IF NO CHANGE IS MADE BY JAVASCRIPT EVERYTHING IS OK
!importantinside your media query code