Hide div element when screen size is smaller than a specific size

前端 未结 9 2160
别跟我提以往
别跟我提以往 2020-12-04 17:41

I have a div element that I want to hide when the width of the browser is less than or equal to 1026px. Is this possible to do with the css: @media only scr

9条回答
  •  失恋的感觉
    2020-12-04 18:18

    This should help:

    if(screen.width<1026){//get the screen width
       //get element form document
       elem.style.display == 'none'//toggle visibility
    }
    

    768 px should be enough as well

提交回复
热议问题