CSS Background Position Shortcuts
I often use divs and background images on a constant basis to get a modern look and feel to a website. When doing so it is important to know the CSS shortcuts for the element background-position.There are two basic ways of writing this in your stylesheet, 1.with Keywords and 2. with Percentages or Lengths.
Keywords
- Horizontal keywords: left, center, right
- Vertical keywords: top, center, bottom
- #header {background: url(/images/header.jpg) top right no-repeat;}
Percentages and/or Lengths
- top left = left top = 0% 0%
- top = top center = center top = 50% 0%
- right top = top right = 100% 0%
- left = left center = center left = 0% 50%
- center = center center = 50% 50%
- right = right center = center right = 100% 50%
- bottom left = left bottom = 0% 100%
- bottom = bottom center = center bottom = 50% 100%
- bottom right = right bottom = 100% 100%
- #header {background: url(/images/header.jpg) 100% 0% no-repeat;}
