0

There is a site specifically that has this effect, I'm wondering if anyone can point me towards a good tutorial to achieve a similar effect. The website is http://www.royalsalute.com/en/whisky. I'd love to know how to get the background image div to stick to the top, have the content scroll with the page, and then have the new background image stick to the top once the user gets there...

Thoughts?

asked Apr 11, 2014 at 19:15

1 Answer 1

1

I think what you're looking for is the background-attachment style.

Here's a fiddle that sort of shows the concept.

http://jsfiddle.net/Lq7zH/

Basically you put your copy inside of another parent div, then you set the parent div's background image, background-size: cover, and background-attachment:fixed;

so HTML

<div class="sticky-div">
 <p>Lots of copy here or other divs or whatever</p>
</div>

CSS

.sticky-div {
 background-image: url(someimage.jpg);
 background-size: cover // ensures it fills the space
 background-attachment: fixed // Makes the background static, as in it doesn't scroll
answered Apr 11, 2014 at 20:03
Sign up to request clarification or add additional context in comments.

2 Comments

But what happens when you want to have multiple background images come in, at various points.
Sorry I didn't see your reply until now :P I'm sure you've solved it. Anyhow, if you want to have several different background images come in, then you just layer multiple divs using the above technique. Check out slaphands.com/process for an example. Essentially what you've got to remember is that even though that image doesn't look like it's moving, the div it's in actually is. So when you reach the end of that div, the next one will come in.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.