Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialDaniel Oropeza
4,432 PointsAchieving a background image effect similar to this one?
Take a look at the responsiveboat wordpress theme. As one scrolls the background image, the bottom portion of the background image is gradually hidden behind the div under it.
I'm sorry I don't really know how to elaborate on my description any further.
I have no idea if its a script effect or what.
I reaaally want to achieve this effect for a website I'm trying to build. Any help would be greatly appreciated.
3 Answers
Craig Watson
27,930 PointsHi Daniel,
For the first section that is just a fixed background image using css:
.selector {
background-image: url('my-image.jpg');
background-repeat: no-repeat;
background-attachment: fixed;
}
This in itself can really smarten up the design of a site.
To achieve the affect of the objects coming in as you scroll you need a little javascript or In your case I would use jQuery to keep it simple and you already have it with WordPress so might as well use it.
I have only visited one site that implements a decent version of what is known as the parallax effect, and that is apple.com.
There are plugins and many have tried but if you get it wrong and it ends up jerky and sticky, it is going to ruin a decent site by making it look like it is slow.
I have made some adjustments to a pen i was working on a while ago here where I use css transforms and a little jQuery to slide sections up when they come in to view. You could certainly utilize the jQuery to add your own effects.
Here is another pen that uses jQuery to add a shadow to the navbar on scroll. You can add any css you like however this technique shouldn't be used for other items on the page as you would need to specify explicit scroll top values and in responsive design that may be near impossible.
The about us section and testimonials sections have just been given a rgba() value with a low alpha for example the about us may be rgba(0, 0, 0, 0.2), because there is a fixed image it can then be seen through the semi transparent rgba you have just declared and the same goes for testimonials it is just a yellow rgba with a semi transparent alpha.
It is a pretty neat trick really.
Hope this helps and I really like the theme and the semi transparent backgrounds over the fixed image, if you want me to whip up a pen to show you some code of how i would do it just let me know :)
Craig
Jeff Kinley
21,207 PointsIf I hear you correctly, what you are referring to is called parallax effect. I believe there a number of ways to achieve this using HTML and CSS. I'd start by doing a Google search to become more familiar. I have not seen a tutorial on Treehouse yet, but there may be one. Good luck!
Daniel Oropeza
4,432 PointsThe Parallax effect! Thanks guys. I'm definitely gonna have some fun working with this feature. Haven't really dived into JQuerry yet, but I'm beginning to get some idea of what is possible. Also, those code pens are really neat thanks for sharing those.