javascript - Background image scale to screen size not to the content -


i setting background image of each page using following js

 var image = 'url(' + imageurl + ') top left no-repeat fixed';         $('body').css({ 'background': image }); 

by setting "background-size:cover!important;" able scale image according page content's height & width.

my requirement scale background image according screen size , not according page content size.

basically facing problem in mobile view.

you setting background body. body is page content size.

if create div directly on body.

html

<body>   <div class="page-bg"></div>    <!-- page content --> </body> 

css

.page-bg {   max-height: 100vh;   min-height: 100vh;   width: 100%;   /* background styles */ } 

Comments