CSS Tutorial





Español Français 中文 Deutsch Portuguese Japanese nederlands
   
 
CSS Topics
css tutorials Introduction
Types Types
Background Properties Background Properties
Text Properties Text Properties
Font Properties Font Properties
Box Properties BOX Properties
Border Properties Border Properties
Margin Properties Margin Properties
Padding Properties Padding Properties
Special Topics Special Topics
Forums Ask Your Doubts
Scraps More about CSS
Feedback Feedback
 




CSS Background Attachment


Tutorials Css

Topic

How to set a fixed image? Set the image to scroll with the page and always be seen at the top?
How to set the background image in the html page to be in the same position?



Explanation


Property: Background Attachment

Usage:
background-attachment: scroll;
background-attachment: fixed;

Definition:
This tag sets the property of how the background image should behave. Whether it should scroll with the page or be static.
It takes the following values.

a)scroll : The image will scroll with the page
b)fixed : The image will not scroll with the page. It will be static. The content will be moving but not the image

Examples

<body style="background-image: url('test3.jpg'); background-repeat: no-repeat; background-position: center; background-attachment: scroll;"> color name <br><br><br></body>

Result:

<body style="background-image: url('test3.jpg'); background-repeat: no-repeat; background-position: center; background-attachment: fixed;"> color name <br><br><br></body>


Result:

with scroll:
It the default behaviour.

with fixed:
The image shown in this page is an example of fixed.

Thus we can get the fixed background image.
Background position Word spacing


A Note
CSS - Cascading Style Sheets can be used along with html tags as explained in this site. This simple CSS will help you to create much elegant and neat html web pages. This does not need any additional softwares or codings. All web browser are capable of handing CSS codes.

Note 2: If required you can using <span> instead of <div> tags. div tag will start and end on new lines. span will not exceed the tag area.
Other Links

web hosting