Jeff Gong
Jeff Gong

Reputation: 1863

How to stop a photo's positioning from changing as you scroll

I have a photo positioned as my background photo for my landing page. As I scroll down, I'd like the photo's positioning to remain the same relative to the viewer, but I'm having issues doing this.

http://ellensriley.com/#about

In this person's website, for example, the girl's face has the same positioning even as you scroll and advance to the next part of the page. Help is greatly appreciated!

Upvotes: 0

Views: 25

Answers (1)

potatopeelings
potatopeelings

Reputation: 41065

Use CSS background-attachment: fixed (https://developer.mozilla.org/en-US/docs/Web/CSS/background-attachment)

body {
    background: url(mypicture.png) no-repeat;
    background-attachment: fixed;
}

Replace mypicture.png with your image path

Upvotes: 1

Related Questions