So, many moons ago, I wrote a post about how to make iOS style “Back” and “Next” buttons using CSS. Only problem was that technique used a span tag to create the pointer. For some reason it slipped my mind that I could use the CSS generated content property with the :before pseudo-element. Rather than being bothered with having to stick spans into buttons to turn them into pointers, I now introduce you to a more sane method of creating “Back” and “Next” buttons with just CSS.
Now you might be wondering how we would generate the node we need to style as a pointer. Using the CSS content property we can generate automatic content inside the button, removing the necessity of having a tag sitting there for no other reason. Unfortunately the content property only generates alpha-numeric content. We can’t use it to create a span or any other tag. But we don’t have to use a normal character as the content. A space will suffice to create the desired pointer. We make it display as a block element and then style it as if it were a normal pointer. Problem solved.
To accomplish our goal we need to switch out any reference to < span.pointer for :before
So, here’s the styles for a normal button, followed by the styles for the pointer.
.button.bordered.back:before { content: " "; display: block; z-index: 0; background-image: -webkit-gradient(linear, left top, right bottom, from(#92a1bf), color-stop(0.3, #798aad), color-stop(0.51, #6276a0), color-stop(0.51, #556a97), color-stop(0.75, #566c98), to(#546993)); border-left: solid 1px #484e59; border-bottom: solid 1px #9aa5bb; -webkit-border-top-left-radius: 5px; -webkit-border-bottom-right-radius: 5px; -webkit-border-bottom-left-radius: 4px; height: 23.5px; width: 23.5px; display: inline-block; -webkit-transform: rotate(45deg); -webkit-mask-image: -webkit-gradient(linear, left bottom, right top, from(#000000), color-stop(0.5,#000000), color-stop(0.5, transparent), to(transparent)); position: absolute; left: -9px; top: 2.5px; -webkit-background-clip: content; } .button.bordered.back:hover:before, .button.bordered.back.touched:before { background-image: -webkit-gradient(linear, left top, right bottom, from(#7d88a5), color-stop(0.3, #58698c), color-stop(0.51, #3a4e78), color-stop(0.51, #253c6a), color-stop(0.75, #273f6d), to(#273f6d)); }
You can check out the finished version online or download the source code.
Image may be NSFW.
Clik here to view.

Clik here to view.
