MDN self-hosted library · e01.org

Implementing image sprites in CSS

Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.

css
.tool-btn {
  background: url("myfile.png");
  display: inline-block;
  height: 20px;
  width: 20px;
}
css
#btn1 {
  background-position: -20px 0px;
}

#btn2 {
  background-position: -40px 0px;
}