CSS Lecture 8 (Image Sprite)
CSS Lecture 8 (Image Sprite)
.sprite {
background: url("images/mySprite.png") no-repeat;
}
• Now, we must define a class for each item we want to display. For example,
to display Internet Explorer icon form the image sprite the CSS code would
be.
.ie {
width: 50px; /* Icon width */
height: 50px; /* Icon height */
display: inline-block; /* Display icon as inline block */
background-position: 0 -200px;
/* Icon background position in sprite */
}
<!DOCTYPE html> .ie {
<html lang="en"> width: 50px; /* Icon width */
height: 50px; /* Icon height */
<head>
display: inline-block; /* Display
<meta charset="utf-8"> icon as inline block */
<title>Example of CSS background-position: 0 -200px; /*
Sprite</title> Icon background position in sprite */
<style> }
</style>
.sprite {
</head>
background:
<body>
url("/examples/images/mySprite.p
ng") no-repeat; <span class="sprite ie"></span>
</body>
}
</html>
• Output:
• The clear property specifies what should happen with the element
that is next to a floating element.
• The clear property controls the flow next to floated elements.
• Sytax:
• clear: none|left|right|both|initial|inherit;
Value Description
none Default. The element is not pushed below left or right floated
elements
left The element is pushed below left floated elements
right The element is pushed below right floated elements
both The element is pushed below both left and right floated elements
initial Sets this property to its default value.
inherit Inherits this property from its parent element.
<!DOCTYPE html> <body>
<html>
<head> <h1>The clear Property</h1>
<style>
img {
<img src="birdimage.jpeg"
float: left; width="100" height="132">
}