mardi 23 avril 2019

I want to create a function that changes image size when her div size changes

I have a header with an image.I want when the header changes his size the image that`s in him to change as well. Down here in the box i have the code that i was trying to run

when i change the size of my header to be 80 ,image to be 80 height as well,and when i set it to height 100 ,image to be 100.

const mainNav = document.querySelector('.header');
const img = document.querySelector('.logo');


function changeLogo() {
 if (mainNav.style.height === '80px') {
        img.style.height = '80px';
    } else {
     img.style.height = '100px';
    }
}
changeLogo();

Aucun commentaire:

Enregistrer un commentaire