How to fix the image background if the web page is scrollable
I have a web page which is scrollable, i need to make the image background开发者_如何学运维 fixed so that it doesn't repeat when i scroll, i try this :
<body style="background:url(background.png);background-attachement: fixed;">
The image is displayed but it's repeated when the web page is scrollable which make it ugly.
You need to add background-repeat:no-repeat;
. Also depending on your situation you might have to add a !important
modifier at the end of the rule. Check Demo: http://jsfiddle.net/bhbAv/ . If that doesn't work for you don't forget to add the !important
at the end.
You should really do this all in one statement too where possible, such as:
<body style="background:url(background.png) no-repeat fixed;">
You're looking for:
background-attachment:fixed;
You typed:
background-attach_E_ment: fixed;
Yes I agree, probably background-attachment:fixed; would do it.
Take a look at this: http://www.w3schools.com/css/css_background.asp
精彩评论