Reputation: 3896
Is there a way to make the background image move when you scroll the page up and down, whenever i scroll up and down the background image stays still but I want it to move with the page, is that possible?
Upvotes: 1
Views: 4284
Reputation: 13660
Simply set the attachment to fixed
.
background-attachment:fixed;
If you have a large image, you can use background-size
.
For example:
html {
background: url(images/bg.jpg) no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}-
background-size
does what it tells you. Using cover
as the attribute, the background image is scaled to fill the entire background, thus getting rid of the scrollbars when using an image larger than your screen.
Upvotes: 2
Reputation: 45162
Mozilla docs: https://developer.mozilla.org/en-US/docs/Web/CSS/background-attachment
Upvotes: 1