basics of web design chapter 6 more css basics key concepts

33
Basics of Web Design Chapter 6 More CSS Basics Key Concepts

Upload: zoe-higgins

Post on 16-Dec-2015

227 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Basics of Web Design Chapter 6 More CSS Basics Key Concepts

Basics of Web Design

Chapter 6

More CSS Basics

Key Concepts

Page 2: Basics of Web Design Chapter 6 More CSS Basics Key Concepts

Learning Outcomes

Apply shadows with CSS3

Configure rounded corners with CSS3

Configure background images with CSS3

Configure opacity, RGBA color, HSLA color, and gradients with CSS3

Page 3: Basics of Web Design Chapter 6 More CSS Basics Key Concepts

CSS3 Rounded Corners

Before CSS3, if web designers wanted boxes with rounded corners, they had to use images.

CSS3 introduced a new property, border-radius, that allows web designers to have rounded borders without using images.

Page 4: Basics of Web Design Chapter 6 More CSS Basics Key Concepts

border-*-radius Properties

The property value contains one or two length/percentage values. These values define the radii of a quarter ellipse that defines the shape of the corner of the border.

The first value is the horizontal radius while the second value is the vertical radius.

If the second value is omitted, its value is the same as the first value.

If either value is 0, then the corner is square, not rounded.

Page 5: Basics of Web Design Chapter 6 More CSS Basics Key Concepts

border-top-left-radius Property

The border-top-left-radius property defines the shape of the border of the top-left corner and allows us to have rounded borders.

Red is the horizontal radiusBlue is the vertical radius

Page 6: Basics of Web Design Chapter 6 More CSS Basics Key Concepts

border-top-right-radius Property

The border-top-right-radius property defines the shape of the border of the top-right corner and allows us to have rounded borders.

Red is the horizontal radiusBlue is the vertical radius

border-top-right-radius: 50px 100px;

border-top-right-radius: 100px 50px;

border-top-right-radius: 50px 50px;

border-top-right-radius: 50px;

Page 7: Basics of Web Design Chapter 6 More CSS Basics Key Concepts

border-bottom-left-radius Property

The border-bottom-left-radius property defines the shape of the border of the bottom-left corner and allows us to have rounded borders.

Red is the horizontal radiusBlue is the vertical radius

border-bottom-left-radius: 50px 100px;

border-bottom-left-radius: 100px 50px;

border-bottom-left-radius: 50px 50px;

border-bottom-left-radius: 50px;

Page 8: Basics of Web Design Chapter 6 More CSS Basics Key Concepts

border-bottom-right-radius Property

The border-bottom-right-radius property defines the shape of the border of the bottom-right corner and allows us to have rounded borders.

Red is the horizontal radiusBlue is the vertical radius

border-bottom-right-radius: 50px 100px;

border-bottom-right-radius: 100px 50px;

border-bottom-right-radius: 50px 50px;

border-bottom-right-radius: 50px;

Page 9: Basics of Web Design Chapter 6 More CSS Basics Key Concepts

border-radius Property

The border-radius property is used to add rounded borders to elements. It is a shorthand property for the border-top-left-radius, border-top-right-radius, border-bottom-left-radius, and border-bottom-right-radius.

Example:

div {border: 2px solid #FF0000;border-radius: 25px 20px 15px 30px / 30px

15px 20px 25px;}

top-left

top-right

bottom-right

bottom-left

top-left

top-right

bottom-right

bottom-left

If bottom-left is omitted it is the same as top-right. If bottom-right is omitted it is the same as top-left. If top-right is omitted it is the same as top-left.

Page 10: Basics of Web Design Chapter 6 More CSS Basics Key Concepts

box-shadow Property

The box-shadow property attaches one or more drop-shadows to the box.

Required values are the position of the horizontal shadow and the position of the vertical shadow.

Optional values include the blur distance, the size of the shadow (spread), the color of the shadow, and whether the shadow is outset (default) or inset.

You can set multiple shadows on a box with a comma separated list

Example:

div {    box-shadow: 10px 10px 5px 10px #888888;}

Page 11: Basics of Web Design Chapter 6 More CSS Basics Key Concepts

text-shadow Property

The text-shadow property adds shadow to your text.

You can have multiple shadows applied to a single piece of text using a comma separated list.

Required values are the position of the horizontal shadow and the position of the vertical shadow.

Optional values include the blur radius and the color of the shadow.

Example:

div { text-shadow: 0px 0px 4px #FFF, 0px -5px 4px #FF3, 2px -10px 6px #FD3, -2px -15px 11px #F80, 2px -25px 18px #F20; }

Page 12: Basics of Web Design Chapter 6 More CSS Basics Key Concepts

text-shadow Property

Examples of what can be accomplished with the text-shadow property

Page 13: Basics of Web Design Chapter 6 More CSS Basics Key Concepts

background-clip Property

The background-clip property specifies the painting area of the background. It confines the display of the background image.

Values are:

border-box (default)

padding-box

content-box

Page 14: Basics of Web Design Chapter 6 More CSS Basics Key Concepts

background-origin Property

The background-origin property specifies what the background-position property should be relative to.

Values are:

border-box

padding-box (default)

content-box

Page 15: Basics of Web Design Chapter 6 More CSS Basics Key Concepts

background-size Property

The background-size property specifies the size of the background image. It can be used to resize or scale the background image.

Example:

div {    background: url(img_flwr.gif);    background-size: 35%;    background-repeat: no-repeat;}

Original image

Resized image

Page 16: Basics of Web Design Chapter 6 More CSS Basics Key Concepts

opacity Property

The opacity property sets the opacity level for an element.

1 is completely opaque (default), 0.5 is 50% see-through, and 0 is completely transparent.

Example:

h1{background-color: #FFFFFF;opacity: 0.6;

}

Page 17: Basics of Web Design Chapter 6 More CSS Basics Key Concepts

Understanding Color

Page 18: Basics of Web Design Chapter 6 More CSS Basics Key Concepts

Understanding Color

The colors on your monitor are made by mixing red, green, and blue.

We’ve been using hexadecimal values to represent the red, green, and blue values to create color.

A select group of colors also have HTML color names

We can also specify color using RGB(a) and HSL(a)

Page 19: Basics of Web Design Chapter 6 More CSS Basics Key Concepts

RGB Color

RGB color requires three values:

Red color

Green color

Blue color

The values for red, green, and blue must be decimal values from 0 to 255.

Example:

h1 { color: rgb(102,205,170); }

RGB VALUES

rgb(102,205,170)

Page 20: Basics of Web Design Chapter 6 More CSS Basics Key Concepts

RGBA Color

RGBA color is an extension of the RGB color values by adding in an alpha channel.

The alpha channel specifies the opacity of the color.

RGBA color requires four values: Red color, Green color, Blue color, and Alpha (transparency)

The values for red, green and blue must be decimal values from 0 to 255.

The alpha value must be a number between 0 (transparent) and 1 (opaque)

Example:h1 { color: #ffffff;

color: rgba(255, 255, 255, 0.7); }

Page 21: Basics of Web Design Chapter 6 More CSS Basics Key Concepts

HSL Color

Hue is a degree on the color wheel (from 0 to 360) 0 (or 360) is red, 120 is green, 240 is blue

Saturation is a percentage value 0% means a shade of gray and 100% is the full color

Lightness is also a percentage value 0% is black and 100% is white.

LIGHTNESSSATURATIONHUE

Page 22: Basics of Web Design Chapter 6 More CSS Basics Key Concepts

HSL Color

Using the HSL color, you specify the degree of the hue, the percentage of saturation, and the percentage of lightness.

Example:

h1 {background-color: hsl(120, 100%, 50%);}

THIS IS MY HEADING

Page 23: Basics of Web Design Chapter 6 More CSS Basics Key Concepts

HSLA Color

HSLA color is an extension of the HSL color values by adding in an alpha channel.

The alpha channel specifies the opacity of the color.

HSLA color requires four values: degree of the hue, percentage of saturation, percentage of lightness, and alpha (transparency)

The value for hue must be a value between 0 and 360 while the values for saturation and lightness must be a percent between 0% and 100%.

The alpha value must be a number between 0 (transparent) and 1 (opaque)

Example:h1 {background-color: hsla(120, 100%, 100%, 0.7);} 

Page 24: Basics of Web Design Chapter 6 More CSS Basics Key Concepts

CSS3 Gradients

Gradient: a smooth blending of shades from one color to another.

Before CSS3, you would have to use images to have gradients. Now we can use CSS.

Use the background-image property

linear-gradient()

radial-gradient()

Page 25: Basics of Web Design Chapter 6 More CSS Basics Key Concepts

linear-gradient

Use linear-gradient as a value of the background property.

At a minimum, you must declare two values, the starting color and the ending color

Example:

#grad {background: linear-gradient(#FF0000, #0000FF);}

Page 26: Basics of Web Design Chapter 6 More CSS Basics Key Concepts

linear-gradient

You can also specify the direction you want the gradient to go in To right

To left

To top

To bottom

You can also specify an angle to have more control over the direction of the gradient (45deg, 90deg, 180deg)

Example: #grad {background: linear-gradient(to left, #FF0000, #0000FF);}

#grad {background: linear-gradient(45deg, #FF0000, #0000FF);}

To top left

To top right

To bottom left

To bottom right

Page 27: Basics of Web Design Chapter 6 More CSS Basics Key Concepts

linear-gradient

You can also set multiple gradient stops in a linear gradient

For example, if you want a rainbow:

#grad {background: linear-gradient(to right, red,orange,yellow,green,blue,indigo,violet);}

Page 28: Basics of Web Design Chapter 6 More CSS Basics Key Concepts

radial-gradient

A radial-gradient is defined by its center.

You must define at least two color stops.

By default, a radial gradient shape is an ellipse, size is farthest corner, and position is center.

Example:

#grad {background: radial-gradient(red, green, blue);}

Page 29: Basics of Web Design Chapter 6 More CSS Basics Key Concepts

radial-gradient

You can set the shape and the value is either circle or ellipse (default).

Example:

#grad {background: radial-gradient(circle, red, yellow, green);}

You can also set the size of the gradient using the following values:

closest-side

farthest-side

closest-corner

farthest-corner

Example:

#grad {background: radial-gradient(farthest-side at 60% 55%,blue,green,yellow,black);}

Page 30: Basics of Web Design Chapter 6 More CSS Basics Key Concepts

Summary

This chapter expanded your CSS skillset

You configured text with CSS properties

You were introduced to the box model.

You configured CSS properties related to the box model, such as margin, border, padding, and width

You centered a web page using CSS.

You explored new CSS3 properties including:

border-radius

box-shadow

text-shadow

opacity

Page 31: Basics of Web Design Chapter 6 More CSS Basics Key Concepts

Coding Examples

Page 32: Basics of Web Design Chapter 6 More CSS Basics Key Concepts

Questions?

Page 33: Basics of Web Design Chapter 6 More CSS Basics Key Concepts

Homework