removing an important style tag from a media query

31 Views Asked by At

What's the javascript code to change the style to this?

`@media only screen and (max-width: 480px)
.contentpageDefaultLandingPageTemplate .contentRoot {
    width: 320px !important;
}
`

I want to make it as width: 100% !important.

1

There are 1 best solutions below

0
Manush On

I guess you are asking about the javascript implementation of the CSS code. If that's the case, below is the javascript for the CSS

const rootElement = document.querySelector('.contentpageDefaultLandingPageTemplate .contentRoot');

if (window.innerWidth <= 480) {
  rootElement.style.width = '320px';
}