Chapter 13 (CSS Colors and Backgrounds)
Chapter 13 (CSS Colors and Backgrounds)
• The hexadecimal numbering system uses 16 digits: 0–9 and A–F. The hex system is
used widely in computing because it reduces the space it takes to store certain
information.
• For example, the RGB values are reduced from three to two digits once they’re
converted to hexadecimal.
• Now that most graphics and web development software provides easy access to
hexadecimal color values.
RGBa Color 6
• RGBa color allows you to specify a color and make it as transparent or as opaque as
you like.
• The “a” in “RGBa” stands for alpha, which is an additional channel that controls the
level of transparency on a scale from 0 (fully transparent) to 1 (fully opaque).
AA
Transparency
Value
#ff000088
Foreground Color 7
• The foreground of an element consists of its text and border. You specify a foreground
color with the color property.
Background Color 8
• CSS3 introduced the background-clip property to give designers more control over
where the painting area begins and ends.
Opacity 10
• The opacity setting applies to the entire element—both the foreground and the
background. If you want to affect just one use an RGBa.
Background Images 11
• Images tile left and right, up and down, when left to their own devices. You can change
this behavior with the background repeat property.
• The remaining keyword values, space and round, attempt to fill the available
background painting area an even number of times.
Background Position 13
• The background-position property specifies the position of the origin image in the
background.
• You can think of the origin image as the first image that is placed in the background
from which tiling images extend. Here is the property and its various values.
Background Position … 14
Background Position Origin 15
• When the origin image was placed in the corner of an element, it was placed inside the
border.
• This property defines the boundaries of the background positioning area in the same
way background-clip defined the background painting area
Background Attachment 16
• The local value is useful when an element has its own scrolling mechanism. Instead of
scrolling with the viewport’s scroller, local makes the background image fixed to the
content of the scrolling element.
Background Size 17
• You can change the size of the image by using the background-size property.
The Shorthand Background Property 18
• You can use the handy background property to specify all of your background styles in
one declaration.
Color Gradients 19
• A gradient is a transition from one color to another, sometimes through multiple colors.
• Although they are specified with code, gradients are images. They just happen to be
generated on the fly.
• A gradient image has no intrinsic size or proportions; the size matches the element it
gets applied to. Gradients can be applied anywhere an image may be applied:
background-image, border-image, and list-style-image.
The radial-gradient() notation allows you to specify the shape, size, and center position
of the gradient:
1) Shape: The shape specified by using the circle or ellipse keywords.
2) Size: If you supply just one length, it is used for both width and height, resulting in
a circle. When you provide two lengths, the first one is the horizontal measurement
and the second is vertical
3) Position: By default, the center of the gradient is positioned at center center, but
can be changed as background-position property syntax with at keyword. There
are four keywords—closest-side, closest-corner, farthestside, and farthest-
corner .
Repeating Gradients 22