Cascading Style Sheets 3.0 Tutorial

Linear Gradients

Linear gradients are super easy. The property that controls this is background or background-image and the value is the linear-gradient() function. For example:

#header {
	background-color: #369;
	background-image: linear-gradient(to bottom, #ddd, #369);
	border: 1px solid #333;
	padding: 25px;
	text-align: center;
}

Document Heading

#header {
	background-color: #369;
	background-image: linear-gradient(to top, #ddd, #369);
	border: 1px solid #333;
	padding: 25px;
	text-align: center;
}

Document Heading

Radial Gradients

Radial gradients are just as easy. The property that controls this is background or background-image and the value is the radial-gradient() function. For example:

#header {
	background-color: #369;
	background-image: radial-gradient(ellipse, blue, yellow);
	border: 1px solid #333;
	padding: 25px;
	text-align: center;
}

Document Heading

#header {
	background-color: #369;
	background-image: radial-gradient(circle, blue, yellow);
	border: 1px solid #333;
	padding: 25px;
	text-align: center;
}

Document Heading

Supply a percentage to tell the browser how fast to blend the colors together. For example, here, blue starts and then slowly blends to yellow then the rest of the 100% (15%) is for red, green and black to blend.

#header {
	background-color: #369;
	background-image: radial-gradient(circle, blue 10%, yellow 75%, red, green, black);
	border: 1px solid #333;
	padding: 25px;
	text-align: center;
}

Document Heading

Repeating Radial Gradients

Repeating radial gradients are also a snap in CSS3. Simply use the repeating-radial-gradient function value for the background-image property.

#header {
	background-image: repeating-radial-gradient(circle, yellow, blue 5%);
}

Document Heading

Images

Place an image in the content of the document using the HTML <img> tag. To have text and other page elements wrap around an image specify a float value of either left or right. To add space between the image and its document content, use the margin property. Finally, specify a border using the border property.

<< < [Page 11 of 15] > >>