BackgroundBackground imageWe can use a picture as background of a page, or a paragraph, or a DIV section.For example, we can use this picture (green.jpg)... ...as background of a DIV section, using an instruction like this:
DIV.green { background-image : url("green.jpg"); }
<DIV class="green">This background is green.</DIV>
This background is green.
Background repeatA background image can cover an area like a tile in four ways:
Background positionA background image can be placed on a specified position of the page.
BODY { background-position : right; }
The default value of the vertical position is center.
To specify a different vertical position we must declare it as second value, this way:
BODY { background-position : right top; }
Background attachmentUsing this instruction, the background image of the BODY becomes static, and does not scroll (see this example) :
BODY { background-attachment : fixed; }
Next page : how to publish an HTML document on the web. |