
VERSION 2 COMING SOON.. SEE THE FIDDLE ON THE BOTTOM OF THE PAGE
see the iOS 6 Version here
I added a third version without the use of -webkit-mask-image on request. (Compatible with Firefox and Opera)
I recently needed to make CSS arrow buttons for iOS devices.
There are a few examples and sourcecodes on the www, but they all don’t seem perfect.
They all basically rotate a square and then use a mask to hide the unneeded part. This square is added with the pseudo-class :before or :after.
Sencha Touch
css3wizardry
hedgerwow
jeffbatterton

However a square does not give the correct angle since a square has 4 corners with 90deg angles and flat sides. “iOS arrows” have an angle of about 95deg – 100deg with slightly rounded (bent) sides. Jeffbatterton’s example uses a rhombus, but it really doesn’t look good and the markup is terrible since he’s not using the pseudo-classes :before and :after. I also added a “skew” to make a rhombus instead of a square and then rotated it, to make the arrow part a little slimmer, just like it is in iOS. To get the sides to look bent, I basically used two different curves.
One is applied to the main element’s left side…

border-radius: 6px; -webkit-border-top-left-radius : 10px 15px; -webkit-border-bottom-left-radius : 10px 15px; |
…and the second one is applied to the sides of the rhombus.

-webkit-transform : rotate(-45deg) skew(-10deg, -10deg); -webkit-border-top-right-radius : 100px 40px; -webkit-border-top-left-radius : 30px 2px; -webkit-border-bottom-right-radius : 2px 30px; -webkit-border-bottom-left-radius : 40px 100px; |
both together look like this.

Then we can mask the rhombus at about 33% – 50% to use both curves (I am using a fading gradient). Due to the rounded corners we now have an angle of about 96-97deg.

-webkit-mask-image : -webkit-gradient(linear, left top, right bottom, from(#000000), color-stop(0.33,#000000), color-stop(0.5, transparent), to(transparent)); } |
Using gradients like in the example below is a little complex, since the gradient is always relative to the height of the element. You can try to play around with background-image-size or just use a flat color to get better results.

#ios-arrow-left { left:20px;/*change the position*/ top:10px;/*change the position*/ position:absolute; background-repeat:repeat-x; background-color: rgba(74,108,155,1);/*change this and the background color for the :before element*/ background-image : -webkit-linear-gradient( bottom, rgba(0,0,0,0) 0%, rgba(0,0,0,0) 50%, rgba(255,255,255,0.1) 50%, rgba(255,255,255,0.3) 100% ); height:30px; padding: 0 10px 0 8px; z-index : 0; border-radius: 6px; -webkit-border-top-left-radius : 10px 15px; -webkit-border-bottom-left-radius : 10px 15px; border-bottom: 1px solid rgba(255,255,255,0.3); box-shadow :-1px -1px 0px rgba(0,0,0,0.2)inset, 0 1px 2px rgba(0,0,0,0.8)inset; font-size : 11px; display : block; text-align:center; color:#fff; text-shadow : 0px -1px 0px #000; line-height : 30px; font-family : HelveticaNeue; font-weight: 700; -webkit-background-size : 30px; } #ios-arrow-left:before{ position:absolute; top:9.9%; left:-5px; -webkit-background-size : 22px 22px; background-position :-2px -1.5px; background-color: rgba(74,108,155,1);/*change to the same as the main element*/ background-image : -webkit-gradient(linear, left bottom, right top, from(rgba(0,0,0,0)), color-stop(0.5, rgba(0,0,0,0)), color-stop(0.5, rgba(255,255,255,0.1)), to(rgba(255,255,255,0.3))); height : 25px; width: 25px; -webkit-transform : rotate(-45deg) skew(-10deg, -10deg); -webkit-border-top-right-radius : 100px 40px; -webkit-border-top-left-radius : 30px 2px; -webkit-border-bottom-right-radius : 2px 30px; -webkit-border-bottom-left-radius : 40px 100px; z-index : 1; content : ' '; border-left : 1.5px solid rgba(255,255,255,0.3); box-shadow : 1px 1px 0 rgba(0,0,0,0.2) inset, -1px 1px 1px rgba(0,0,0,0.5) inset; -webkit-mask-image : -webkit-gradient(linear, left top, right bottom, from(#000000), color-stop(0.33,#000000), color-stop(0.5, transparent), to(transparent)); } |
Style it to your needs
stylable element debugging:

Comparison:
Original iOS 5

my Version 2
(work in progress)

my Version 1

Sencha Touch

CSS3wizardry

hedgerwow

jeffbatterton

Since this is pure CSS3 it will always display as crisp and sharp as possible on any screen resolution.
you can see the result in the image above or watch it live in the fiddle below (webkit Browsers only )
Version 1
Version 2
Version 2 with “Forward” Arrow
Cross browser version (Opera, Firefox compatible)
Incoming search terms:
ios back button, css3 arrow, css arrow button, css3 arrow buttons, arrow button css, css3 back button, css ios back button, css3 arrows, css3 arrow button, css arrow buttons, css3 ios back button, back button ios, back button css, ios back button css, ios back button css3, css ios button, back button css3, css ios buttons, ios buttons, ios back button png, ios style buttons css, ios arrow, iPhone Back Button CSS, back button, css iphone back button, IOS ARROWS, ios button css, css3 iphone back button, ios style buttons, button arrow css3,









Pingback: arrow button in pure CSS & HTML - iOS 6 | HTML5 CSS3 Back button arrow