Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS3 button renders differently on web vs iOS

Tags:

css

button

I found some code for generating CSS3 buttons which I'm using on my site. The buttons look great when viewed in the browser. However, on the mobile web version of my site (which uses the same styles) the buttons render differently. Even stranger, if I use Safari and view my site with User Agent of iPhone the buttons look as they should. However in iOS Simulator they don't. Can someone help me understand why?

Here's the code I'm using:

.button, #button .button, li.button .button { 
  display: inline-block; 
  zoom: 1; 
  *display: inline; 
  vertical-align: baseline; 
  outline: none; 
  cursor: pointer; 
  text-align: center; 
  text-decoration: none; 
  font: 14px/100% Arial, Helvetica, sans-serif; 
  padding: .5em 1.5em .55em; 
  text-shadow: 0 1px 1px rgba(0,0,0,.3); 
  -webkit-border-radius: .5em; 
  -moz-border-radius: .5em; 
  border-radius: .5em; 
  -webkit-box-shadow: 0 1px 2px rgba(0,0,0,.2); 
  -moz-box-shadow: 0 1px 2px rgba(0,0,0,.2); 
  box-shadow: 0 1px 2px rgba(0,0,0,.2); 
}

.orange, #button .orange { 
  color: #fef4e9; 
  border: solid 1px #da7c0c; 
  background: #f78d1d; 
  background: -webkit-gradient(linear, left, top, left bottom, from(#faa51a), to(#f47a20)); 
  background: -moz-linear-gradient(top, #faa51a, #f47a20); 
  filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#faa51a', endColorstr='#f47a20'); 
}

Here is how it renders in the browser:

enter image description here

And here is how it renders on an iPhone:

enter image description here

like image 588
tvalent2 Avatar asked Dec 01 '22 00:12

tvalent2


2 Answers

Apply "-webkit-appearance:none;" on your css properties and add this line "input[type=submit], input[type=Reset]{ -webkit-appearance:none; }".

like image 105
Shakti Avatar answered Dec 04 '22 09:12

Shakti


As Shakti says you should just put the following css for the button.

-webkit-appearance: none;

This is explained further in this question:

'CSS submit button weird rendering on iPad/iPhone'

It seems that on iOS the buttons have the default iOS rounded look if you supply just a simple background color :

background: orange

But if you supply a gradient then this is effectively overriding the appearance css property to use a custom style.

But because you had the wrong syntax it was giving you the iOS look.

like image 24
Simon_Weaver Avatar answered Dec 04 '22 11:12

Simon_Weaver