kjtocool Posted May 26, 2008 Share Posted May 26, 2008 I have a huge background image, and the site is centered over it. Whenever the site scrolls, the stupid BG starts to scroll down from the top, but all I want it to do is stay fixed vertically. How can I do this? Currently I use the following style: body { background-position: center; background-color: #000000; background-image: url(images/bg.jpg); background-repeat: no-repeat; margin-top: 200px; } Link to comment https://forums.phpfreaks.com/topic/107302-solved-how-can-i-make-a-background-in-a-fixed-position/ Share on other sites More sharing options...
AndyB Posted May 26, 2008 Share Posted May 26, 2008 remove the background-position declaration Link to comment https://forums.phpfreaks.com/topic/107302-solved-how-can-i-make-a-background-in-a-fixed-position/#findComment-550175 Share on other sites More sharing options...
kjtocool Posted May 26, 2008 Author Share Posted May 26, 2008 Problem is, the site is centered, so that leaves the image aligned to the left, and the site aligned to the center. Any way to get it to stop scrolling while being centered aligned horizontally? Link to comment https://forums.phpfreaks.com/topic/107302-solved-how-can-i-make-a-background-in-a-fixed-position/#findComment-550185 Share on other sites More sharing options...
AndyB Posted May 26, 2008 Share Posted May 26, 2008 http://www.w3schools.com/css/pr_background-position.asp background-position: top center; Link to comment https://forums.phpfreaks.com/topic/107302-solved-how-can-i-make-a-background-in-a-fixed-position/#findComment-550266 Share on other sites More sharing options...
kjtocool Posted May 26, 2008 Author Share Posted May 26, 2008 Thanks for your help Andy, that seems to do the trick. Link to comment https://forums.phpfreaks.com/topic/107302-solved-how-can-i-make-a-background-in-a-fixed-position/#findComment-550273 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.