Skip to content

Instantly share code, notes, and snippets.

@tleunen
Last active December 17, 2015 04:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tleunen/5549333 to your computer and use it in GitHub Desktop.
Save tleunen/5549333 to your computer and use it in GitHub Desktop.
Create an expandable ahref button in width, with 3 background image in css (left, middle and right parts). All this keeping the html very simple.
.cbtn {
position: relative;
top: 0px;
left: 9px; /* same as width of left part (:before) */
background: url(img/middle.png);
height: 50px; /* height of the background image */
color: #000;
display:table-cell;
vertical-align:middle;
text-align:center;
text-decoration: none;
}
.cbtn:before,
.cbtn:after {
content: "";
background: url(img/left.png);
width: 9px; /* width of the image */
height: 50px; /* height of the background image */
position: absolute;
left: -9px; /* same as width */
top: 0px;
}
.cbtn:after {
background: url(img/right.png);
left: auto;
right: -9px; /* same as width */
}
.cbtn:active {
color: #000;
}
.cbtn:hover,
.cbtn:hover:before,
.cbtn:hover:after {
background-position: 0 -50px;
}
.cbtn:active,
.cbtn:active:before,
.cbtn:active:after {
background-position: 0 -100px;
}
<a href="#" class="cbtn">Click me!!!</a>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment