We would like to know how to show only part of an image.
<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
div {<!-- w ww. jav a 2 s. c om-->
width: 200px;
background: url(http://www.java2s.com/style/download.png) no-repeat;
}
.bg-2 {
height: 150px;
}
</style>
</head>
<body>
<div class="bg-1">Lorem ipsum.</div>
<br>
<div class="bg-2">Lorem ipsum.</div>
</body>
</html>
The code above is rendered as follows: