Reputation: 28164
If you look at this page, you notice that the background image does not move
http://livingsocial.com/deals/31570-86-off-boot-camp-classes?msdc_id=13
1) How is this done?
2) Why doesn't Twitter do something similar (ie, what are the UI disadvantages?)
Upvotes: 0
Views: 414
Reputation: 42808
One line is all you need
background:transparent url(img.jpg) no-repeat fixed 0 0;
Upvotes: 1
Reputation: 490143
1) There is a large div
there with the background, and position: fixed
.
position: fixed
means it won't move when the viewport scrolls.
2) I don't know... they probably would if they wanted the functionality.
Upvotes: 1
Reputation: 298096
It's done with pure CSS:
body
{
background-image: url('foo.png');
background-repeat: no-repeat;
background-position: center center;
background-attachment: fixed;
}
Upvotes: 3
Reputation: 253308
You can use:
body {
background: #fff url(path/to/image.png) 0 0 no-repeat;
background-attachment: fixed;
}
As to 'why doesn't Twitter do this?' That's not something we can answer, really, unless the Twitter devs are present on Stack Overflow. Historically using it has meant the page tends to scroll somewhat 'clunkily,' but that might just be the added rendering requirements placed on the browser, rather than implicit in the behaviour, or use, of background-attachment
.
Upvotes: 1