Background

Introduction


background-color

The mainContent div has its own
background-color & background-image

 

This table has it's own background-color

  • The default background-color for elements is transparent.
  • Defining background colors overrides the default.
  • This is why the table color is seen instead of the page's background, and the row's color instead of the table's, and cell's instead of the row's.
 
    This cell has its own background-color
     
This row has its own background-color.    
     
This row has its own background.   This cell has its own background-color
     

background-image


background-repeat


This image is designed to tile in all directions seamlessly Diagonals as
background

Gradient image

Gradient as background
Striped background image

A New Slant On Life!

  • The default of background images is to tile endlessly horizontally and vertically.
  • The background image for this cell was created in a manner that allows it to seamlessly match its right edge with its left edge and its bottom edge with its top edge.
  • Tiling allows designers to take advantage of the default that background images have which causes them to tile in all directions. This provides the appearance of a larger image whilst using just a small one.
  • Such images can be found or generated on the web at various sites.

Duis ligula lorem, consequat eget, tristique nec, auctor quis, purus. Vivamus ut sem. Fusce aliquam nunc vitae purus. Aenean viverra malesuada libero. Fusce ac quam. Donec neque.

Curabitur posuere, pede vitae lacinia accumsan, enim nibh elementum orci, ut volutpat eros sapien nec sapien. Suspendisse neque arcu, ultrices commodo, pellentesque sit amet, ultricies ut, ipsum.

Duis ligula lorem, consequat eget, tristique nec, auctor quis, purus. Vivamus ut sem. Fusce aliquam nunc vitae purus. Aenean viverra malesuada libero. Fusce ac quam. Donec neque.

Nunc venenatis enim nec quam. Cras faucibus, justo vel accumsan aliquam, tellus dui fringilla quam, in condimentum augue lorem non tellus. Pellentesque id arcu non sem placerat iaculis.

Striped background image

Making the Grade!

  • This section's background uses the image of the linear gradient on the left.
  • This cell also has a background color that matches the brighter color at the bottom of the linear gradient.
  • The background image is set to repeat-x.
  • This is what provides the nice blend.
  • Making the image narrow keeps the image file size small.
  • By default, the gradient image would have repeated itself vertically after its height has been fully revealed by its container.
  • In other words, at the point in this background where the entire length of the background image has been accommodated, we would then see the distinct darker top edge of the image as the image begins to repeat vertically.
  • But we do not.
  • This is because the CSS used for this background image is as follows:
    background: url(images/grad.jpg) repeat-x;
  • The gradient's lighter color at the bottom blends seamlessly into the cell's background color.
  • This is a standard method of creating a nice background.
  • Note that normally background images of this nature would be only 1 pixel wide, but I have made it 20 pixels wide so that it is easier for you to see it.
Animated example of tiled aligment

background-attachment


background-position


Background Shorthand

Background shorthand: list the property values in any order. If any of the properties are not represented, the default will be used. Example:

background: #FFD url(images/grad.jpg) repeat-y scroll 0 0;


Assignment

ampersand gradient horizontal graddiagonal pattern for tiling

Additional Information: