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 trial

JavaScript

Is it possible to set the background image as fixed without any css

I wanting to set the background image fixed but having a few issues with chrome so wonder it is possible to do the same thing with jquery or pure javascript without any css?

2 Answers

You can always set a 100%x100% div with a background image and a super low z-index with position: fixed ? That might be kind of a ghetto way of doing it, but it might work.

http://codepen.io/anon/pen/GgryzJ

LOL. Well, it works. I'm not sure why you'd ever want to do it this way. I'm also not sure if it still bugs out in chrome like background-attachment. (I'm not familiar with that bug.)

Position fixed in css should have work fine, background position(x,y) is good for an option as well