Perfect CSS Sprite / Sliding Doors Button | CSS-Tricks | Latest TMZ Celebrity News & Gossip | Watch TMZ Live

Perfect CSS Sprite / Sliding Doors Button

Chris Coyier on

Big note here! Sliding doors is a pretty old technique. It had its time on the web, but it’s probably not the smartest way to go these days. We have border-radius now and gradient backgrounds and all that, which unlock most of what we were trying to achieve back in the day of sliding doors.

But it’s still fun to document how it works, so here it is:

<a href="https://css-tricks.com/#" class="button">
  <span>Sliding Doors Button</span>
</a>
.button {
  float: left;
  clear: both;
  background: url(RIGHT_SIDE.png) top right no-repeat;
  margin: 5px;
  padding-right: 20px;
  color: white;
  text-decoration: none;
}
.button span {
  background: url(LEFT_SIDE.png) top left no-repeat;
  line-height: 22px;
  padding: 7px 0 5px 18px;
  display: block;
}
.button:hover {
  background-position: right -34px;
}
.button:hover span {
  background-position: 0 -34px; color: #fff;
}

Which assumes graphics like these:

See the Pen Sliding Doors Buttons by Chris Coyier (@chriscoyier) on CodePen.

TMZ Celebrity News – Breaking Stories, Videos & Gossip

Looking for the latest TMZ celebrity news? You've come to the right place. From shocking Hollywood scandals to exclusive videos, TMZ delivers it all in real time.

Whether it’s a red carpet slip-up, a viral paparazzi moment, or a legal drama involving your favorite stars, TMZ news is always first to break the story. Stay in the loop with daily updates, insider tips, and jaw-dropping photos.

🎥 Watch TMZ Live

TMZ Live brings you daily celebrity news and interviews straight from the TMZ newsroom. Don’t miss a beat—watch now and see what’s trending in Hollywood.