There is such code:
$('.header-x').css({'background-size': screenWidth + ' auto'}); But it does not work.
Can anyone help with the right decision?
There is such code:
$('.header-x').css({'background-size': screenWidth + ' auto'}); But it does not work.
Can anyone help with the right decision?
setTimeout(() => { screenWidth = 50; document.querySelector('.header-x').style.backgroundSize = screenWidth+'px auto' }, 666); .header-x{ width: 100px; height: 100px; border: 1px solid black; background-image: url(https://cdn2.iconfinder.com/data/icons/travel-roundline/512/wall-512.png); // Ваш косяк в том, что вы забыли единицы измерения. // Так это не работает: background-size: 50 auto; } <div class='header-x'></div> Source: https://ru.stackoverflow.com/questions/687003/
All Articles
$('.header-x').css({'background-size': '100% auto'});Or better.header-x { background-size: 100% auto; }.header-x { background-size: 100% auto; }Of course, only if your.header-xwidth is equal to screenWidth - Evgeny Mironov