HTML Element Style How to - Use one icon and offset display area








Question

We would like to know how to use one icon and offset display area.

Answer


<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'
  src='https://ajax.googleapis.com/ajax/libs/mootools/1.4.1/mootools-nocompat.js'></script>
<style type='text/css'>
a {<!--from  w ww.  jav a2s  . co m-->
  width: 16px;
  height: 16px;
  background-image:url(http://www.java2s.com/style/download.png);
  background-position: 2px 8px;
  display: block;
}

a:hover {
  opacity: 0.5;
}
</style>
</head>
<body>
  <a href=""></a>
</body>
</html>

The code above is rendered as follows: