Can anyone guess what CSS styling I should apply to a button to guess this exact look.
Note: I realize this is the default look for for unstyled buttons on Windows and that I don't have to apply any CSS to get this style, but on Mac and Linux it's not the same, so I can't depend on the default styling of the OS for this. I would have to force this style myself in the css. Anyone knows what CSS styling can consistently produce this effect?
Firefox 3.6.12
Safari 5.0.3
Chrome 8
Internet Explorer 8
For some reason, IE8's propriety filter
property didn't work (it should).
<button>
<span>
<span>
Submit
</span>
</span>
</button>
It seems to work better cross browser with 2 child elements. Using the button
itself as the outer element caused a few issues.
button {
background: none;
border: none;
padding: 0;
}
button span {
display: block;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
border: 1px solid #999;
padding: 0;
background: #F0F0F0;
background: -moz-linear-gradient(top, #F0F0F0 50%, #D4D4D4 50%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(50%,#F0F0F0), color-stop(50%,#D4D4D4));
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#F0F0F0', endColorstr='#D4D4D4',GradientType=0 );
}
button span span {
border: 1px solid #fff;
padding: 10px;
}
See it on jsFiddle.
OK, since I can't see your image, I just took a default button look on my OS (Windows 7). The styling would be something like this (only Firefox taken into account, as I'm too lazy to do a cross-browser version):
a.button {
height: 18px;
padding: 2px 8px;
border: 1px solid #F3F3F3;
-moz-box-shadow: 0 0 0 1px #707070;
-moz-border-radius: 3px;
background: -moz-linear-gradient(top, #F2F2F2 0%, #EBEBEB 50%, #DDDDDD 51%, #CFCFCF 100%);
font: normal 12px sans-serif;
color: black;
text-decoration: none;
}
a.button:hover {
border: 1px solid #ECF7FD;
-moz-box-shadow: 0 0 0 1px #3C7FB1;
background: -moz-linear-gradient(top, #EAF6FD 0%, #D9F0FC 50%, #BEE6FD 51%, #A7D9F5 100%);
}
a.button:active {
padding: 2px 7px 3px 9px;
border: 1px solid #73A7C4;
border-bottom: 0;
-moz-box-shadow: 0 0 0 1px #2C628B;
background: -moz-linear-gradient(top, #E5F4FC 0%, #C4E5F6 50%, #98D1EF 51%, #68B3DB 100%);
}
This is a CSS-only version using CSS3. It won't work in Internet Explorer and Opera will not render the background gradients. So you're best off using images instead of pure CSS.
[EDIT]
A more complete implementation: jsfiddle (feel free to add IE filters and some sort of fallback for Opera and edit my answer to post it - BE BOLD :))
a.button {
height: 18px;
padding: 2px 8px;
border: 1px solid #F3F3F3;
-moz-box-shadow: 0 0 0 1px #707070;
-webkit-box-shadow: 0 0 0 1px #707070;
box-shadow: 0 0 0 1px #707070;
-moz-border-radius: 3px;
-webkit-border-radius: 3px;
border-radius: 3px;
background: -moz-linear-gradient(top, #F2F2F2 0%, #EBEBEB 50%, #DDDDDD 51%, #CFCFCF 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0,#F2F2F2), color-stop(0.5,#EBEBEB),color-stop(0.51,#DDDDDD),color-stop(1,#CFCFCF));
background: linear-gradient(top, #F2F2F2 0%, #EBEBEB 50%, #DDDDDD 51%, #CFCFCF 100%);
font: normal 12px sans-serif;
color: black;
text-decoration: none;
}
a.button:hover {
border: 1px solid #ECF7FD;
-moz-box-shadow: 0 0 0 1px #3C7FB1;
-webkit-box-shadow: 0 0 0 1px #3C7FB1;
box-shadow: 0 0 0 1px #3C7FB1;
background: -moz-linear-gradient(top, #EAF6FD 0%, #D9F0FC 50%, #BEE6FD 51%, #A7D9F5 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0,#EAF6FD), color-stop(0.5,#D9F0FC),color-stop(0.51,#BEE6FD),color-stop(1,#A7D9F5));
background: linear-gradient(top, #EAF6FD 0%, #D9F0FC 50%, #BEE6FD 51%, #A7D9F5 100%);
}
a.button:active {
padding: 2px 7px 3px 9px;
border: 1px solid #73A7C4;
border-bottom: 0;
-moz-box-shadow: 0 0 0 1px #2C628B;
-webkit-box-shadow: 0 0 0 1px #2C628B;
box-shadow: 0 0 0 1px #2C628B;
background: -moz-linear-gradient(top, #E5F4FC 0%, #C4E5F6 50%, #98D1EF 51%, #68B3DB 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0,#E5F4FC), color-stop(0.5,#C4E5F6),color-stop(0.51,#98D1EF),color-stop(1,#68B3DB));
}
<a class="button" href="#">Click me</a>
[Edit 2]
Edited to include IE's Filter. http://jsfiddle.net/Kyle_/aUsxy/3/
Here is a good tutorial on getting the effect you are after:
http://www.monc.se/kitchen/59/scalable-css-buttons-using-png-and-background-colors
It's quite difficult to style a button exactly like that, and in a usable scalable format.
An alternative is to simulate an HTML button, have it as a div with a background image and write some Javascript to simulate the functionality.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With