I’m trying do a button in a responsive layout. It needs to be hidden sometimes and show itself when the screen is small, I see a code that do it with vanilla js. But i’m using typescript, the problem it is in the typing typescript. Can someone help me with that?
thecode
function Menu(e){
let list = document.querySelector('ul');
e.name === 'menu' ? (e.name = "close",list.classList.add('top-[80px]') , list.classList.add('opacity-100')) :( e.name = "menu" ,list.classList.remove('top-[80px]'),list.classList.remove('opacity-100'))
}
2
Answers
you can use button tag with type as any of the following ("radio,checkbox,etc..") so that you can create responsive buttons. To make the button functionable, you must link any other page with the button tag using inline href.
You can achieve this by using media queries in CSS to detect the screen width/height and automatically apply the properties you need
You can find various device size and its respective pixel size in height and width, you can use these to set the button visibility as follows
Read more about media queries here css media query