Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set background size (height & width)?

I'm very new to JavaScript.

My code so far:

$("#Stage").css(
  "background-image",
  "url(BG.jpg)",
  "background-attachment", 
  "fixed"
);

What I want to do is have the background image at a set size so lets say: width: 100% and height: 100%.

like image 946
Chris Lad Avatar asked Jun 29 '26 22:06

Chris Lad


1 Answers

You want to use background-size: 100%. Ensure that its browser support is compatible with your supported platforms.

$("#Stage").css({ 
     "background-image": "url(BG.jpg)", 
     "background-attachment": "fixed",
     "background-size": "100%"
});
like image 174
alex Avatar answered Jul 02 '26 12:07

alex