-1
I built a function to read the size of the window through which the user is accessing the site, compare with a standard break-point that I chose and then adapt the layout. I put an example of change in an icon element that is changed when identified the break-point.
function adaptarBtn () {
let pontoDeParada1 = 768;
let pontoDeParada2 = 900;
let larguraTela = window.innerWidth;
let btnNavegar = document.getElementById("fas");
if(larguraTela >= pontoDeParada1 && larguraTela < pontoDeParada2){
btnNavegar.className = 'fas fa-bars fa-lg';
}else if(larguraTela < pontoDeParada1){
btnNavegar.className = "fas fa-bars";
console.log(btnNavegar);
}
}
It worked, the only problem is that the layout only adapts after I refresh the document, and my intention was to make this happen also while resizing the window by the browser.
How to do?
Put this function to be executed in the javascript onresize event, have a look at https://www.w3schools.com/jsref/event_onresize.asp.
– Benilson
With CSS and @media queries you do this, no?
– Ernesto Casanova