Home > OS >  How do you change css when window size gets to a certain point in javascript
How do you change css when window size gets to a certain point in javascript

Time:05-11

I want the font to adjust when the sc reen size gets to 1050px. How do i do this with javascript

CodePudding user response:

Add this to your css:

@media screen and (min-width: 1050px) {
    body {
        /* set font adjusters here */
    }
}

CodePudding user response:

you can do it with css and javascript

CSS

@media screen and (min-width: 1050px) {
    body {
       font-size: // the value you want
    }
}

JavaScript

if(screen.width < your point) {
  // change font size
}

CodePudding user response:

you need to add event listener

const handleResize = () => {
  if(window.innerHeight > 1050) {
     //you can change font size here
     document.getElementById("yourelement").style.fontSize = "69px";
  }
}
window.addEventListener('resize', handleResize)

  • Related