ITeye博客

css 3 按钮

endual · 2013-03-28 15:10 · ajax · jquery · html · Web前端 · Markdown

CSS3 Gradient Buttons


 / Published in: CSS

  


URL: http://www.webdesignerwall.com/tutorials/css3-gradient-buttons/

 

Expand | Embed | Plain Text

  1. /* CSS3 Gradient Buttons http://www.webdesignerwall.com/tutorials/css3-gradient-buttons/
  2. /* button
  3. ---------------------------------------------- */
  4. .button {
  5. display: inline-block;
  6. zoom: 1; /* zoom and *display = ie7 hack for display:inline-block */
  7. *display: inline;
  8. vertical-align: baseline;
  9. margin: 0 2px;
  10. outline: none;
  11. cursor: pointer;
  12. text-align: center;
  13. text-decoration: none;
  14. font: 14px/100% Arial, Helvetica, sans-serif;
  15. padding: .5em 2em .55em;
  16. text-shadow: 0 1px 1px rgba(0,0,0,.3);
  17. -webkit-border-radius: .5em;
  18. -moz-border-radius: .5em;
  19. border-radius: .5em;
  20. -webkit-box-shadow: 0 1px 2px rgba(0,0,0,.2);
  21. -moz-box-shadow: 0 1px 2px rgba(0,0,0,.2);
  22. box-shadow: 0 1px 2px rgba(0,0,0,.2);
  23. }
  24. .button:hover {
  25. text-decoration: none;
  26. }
  27. .button:active {
  28. position: relative;
  29. top: 1px;
  30. }
  31. .bigrounded {
  32. -webkit-border-radius: 2em;
  33. -moz-border-radius: 2em;
  34. border-radius: 2em;
  35. }
  36. .medium {
  37. font-size: 12px;
  38. padding: .4em 1.5em .42em;
  39. }
  40. .small {
  41. font-size: 11px;
  42. padding: .2em 1em .275em;
  43. }
  44. /* color styles
  45. ---------------------------------------------- */
  46. /* black */
  47. .black {
  48. color: #d7d7d7;
  49. border: solid 1px #333;
  50. background: #333;
  51. background: -webkit-gradient(linear, left top, left bottom, from(#666), to(#000));
  52. background: -moz-linear-gradient(top, #666, #000);
  53. filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#666666', endColorstr='#000000');
  54. }
  55. .black:hover {
  56. background: #000;
  57. background: -webkit-gradient(linear, left top, left bottom, from(#444), to(#000));
  58. background: -moz-linear-gradient(top, #444, #000);
  59. filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#444444', endColorstr='#000000');
  60. }
  61. .black:active {
  62. color: #666;
  63. background: -webkit-gradient(linear, left top, left bottom, from(#000), to(#444));
  64. background: -moz-linear-gradient(top, #000, #444);
  65. filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#000000', endColorstr='#666666');
  66. }
  67. /* gray */
  68. .gray {
  69. color: #e9e9e9;
  70. border: solid 1px #555;
  71. background: #6e6e6e;
  72. background: -webkit-gradient(linear, left top, left bottom, from(#888), to(#575757));
  73. background: -moz-linear-gradient(top, #888, #575757);
  74. filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#888888', endColorstr='#575757');
  75. }
  76. .gray:hover {
  77. background: #616161;
  78. background: -webkit-gradient(linear, left top, left bottom, from(#757575), to(#4b4b4b));
  79. background: -moz-linear-gradient(top, #757575, #4b4b4b);
  80. filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#757575', endColorstr='#4b4b4b');
  81. }
  82. .gray:active {
  83. color: #afafaf;
  84. background: -webkit-gradient(linear, left top, left bottom, from(#575757), to(#888));
  85. background: -moz-linear-gradient(top, #575757, #888);
  86. filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#575757', endColorstr='#888888');
  87. }
  88. /* white */
  89. .white {
  90. color: #606060;
  91. border: solid 1px #b7b7b7;
  92. background: #fff;
  93. background: -webkit-gradient(linear, left top, left bottom, from(#fff), to(#ededed));
  94. background: -moz-linear-gradient(top, #fff, #ededed);
  95. filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffff', endColorstr='#ededed');
  96. }
  97. .white:hover {
  98. background: #ededed;
  99. background: -webkit-gradient(linear, left top, left bottom, from(#fff), to(#dcdcdc));
  100. background: -moz-linear-gradient(top, #fff, #dcdcdc);
  101. filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffff', endColorstr='#dcdcdc');
  102. }
  103. .white:active {
  104. color: #999;
  105. background: -webkit-gradient(linear, left top, left bottom, from(#ededed), to(#fff));
  106. background: -moz-linear-gradient(top, #ededed, #fff);
  107. filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ededed', endColorstr='#ffffff');
  108. }
  109. /* orange */
  110. .orange {
  111. color: #fef4e9;
  112. border: solid 1px #da7c0c;
  113. background: #f78d1d;
  114. background: -webkit-gradient(linear, left top, left bottom, from(#faa51a), to(#f47a20));
  115. background: -moz-linear-gradient(top, #faa51a, #f47a20);
  116. filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#faa51a', endColorstr='#f47a20');
  117. }
  118. .orange:hover {
  119. background: #f47c20;
  120. background: -webkit-gradient(linear, left top, left bottom, from(#f88e11), to(#f06015));
  121. background: -moz-linear-gradient(top, #f88e11, #f06015);
  122. filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#f88e11', endColorstr='#f06015');
  123. }
  124. .orange:active {
  125. color: #fcd3a5;
  126. background: -webkit-gradient(linear, left top, left bottom, from(#f47a20), to(#faa51a));
  127. background: -moz-linear-gradient(top, #f47a20, #faa51a);
  128. filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#f47a20', endColorstr='#faa51a');
  129. }
  130. /* red */
  131. .red {
  132. color: #faddde;
  133. border: solid 1px #980c10;
  134. background: #d81b21;
  135. background: -webkit-gradient(linear, left top, left bottom, from(#ed1c24), to(#aa1317));
  136. background: -moz-linear-gradient(top, #ed1c24, #aa1317);
  137. filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ed1c24', endColorstr='#aa1317');
  138. }
  139. .red:hover {
  140. background: #b61318;
  141. background: -webkit-gradient(linear, left top, left bottom, from(#c9151b), to(#a11115));
  142. background: -moz-linear-gradient(top, #c9151b, #a11115);
  143. filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#c9151b', endColorstr='#a11115');
  144. }
  145. .red:active {
  146. color: #de898c;
  147. background: -webkit-gradient(linear, left top, left bottom, from(#aa1317), to(#ed1c24));
  148. background: -moz-linear-gradient(top, #aa1317, #ed1c24);
  149. filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#aa1317', endColorstr='#ed1c24');
  150. }
  151. /* blue */
  152. .blue {
  153. color: #d9eef7;
  154. border: solid 1px #0076a3;
  155. background: #0095cd;
  156. background: -webkit-gradient(linear, left top, left bottom, from(#00adee), to(#0078a5));
  157. background: -moz-linear-gradient(top, #00adee, #0078a5);
  158. filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#00adee', endColorstr='#0078a5');
  159. }
  160. .blue:hover {
  161. background: #007ead;
  162. background: -webkit-gradient(linear, left top, left bottom, from(#0095cc), to(#00678e));
  163. background: -moz-linear-gradient(top, #0095cc, #00678e);
  164. filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#0095cc', endColorstr='#00678e');
  165. }
  166. .blue:active {
  167. color: #80bed6;
  168. background: -webkit-gradient(linear, left top, left bottom, from(#0078a5), to(#00adee));
  169. background: -moz-linear-gradient(top, #0078a5, #00adee);
  170. filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#0078a5', endColorstr='#00adee');
  171. }
  172. /* rosy */
  173. .rosy {
  174. color: #fae7e9;
  175. border: solid 1px #b73948;
  176. background: #da5867;
  177. background: -webkit-gradient(linear, left top, left bottom, from(#f16c7c), to(#bf404f));
  178. background: -moz-linear-gradient(top, #f16c7c, #bf404f);
  179. filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#f16c7c', endColorstr='#bf404f');
  180. }
  181. .rosy:hover {
  182. background: #ba4b58;
  183. background: -webkit-gradient(linear, left top, left bottom, from(#cf5d6a), to(#a53845));
  184. background: -moz-linear-gradient(top, #cf5d6a, #a53845);
  185. filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#cf5d6a', endColorstr='#a53845');
  186. }
  187. .rosy:active {
  188. color: #dca4ab;
  189. background: -webkit-gradient(linear, left top, left bottom, from(#bf404f), to(#f16c7c));
  190. background: -moz-linear-gradient(top, #bf404f, #f16c7c);
  191. filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#bf404f', endColorstr='#f16c7c');
  192. }
  193. /* green */
  194. .green {
  195. color: #e8f0de;
  196. border: solid 1px #538312;
  197. background: #64991e;
  198. background: -webkit-gradient(linear, left top, left bottom, from(#7db72f), to(#4e7d0e));
  199. background: -moz-linear-gradient(top, #7db72f, #4e7d0e);
  200. filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#7db72f', endColorstr='#4e7d0e');
  201. }
  202. .green:hover {
  203. background: #538018;
  204. background: -webkit-gradient(linear, left top, left bottom, from(#6b9d28), to(#436b0c));
  205. background: -moz-linear-gradient(top, #6b9d28, #436b0c);
  206. filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#6b9d28', endColorstr='#436b0c');
  207. }
  208. .green:active {
  209. color: #a9c08c;
  210. background: -webkit-gradient(linear, left top, left bottom, from(#4e7d0e), to(#7db72f));
  211. background: -moz-linear-gradient(top, #4e7d0e, #7db72f);
  212. filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#4e7d0e', endColorstr='#7db72f');
  213. }
  214. /* pink */
  215. .pink {
  216. color: #feeef5;
  217. border: solid 1px #d2729e;
  218. background: #f895c2;
  219. background: -webkit-gradient(linear, left top, left bottom, from(#feb1d3), to(#f171ab));
  220. background: -moz-linear-gradient(top, #feb1d3, #f171ab);
  221. filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#feb1d3', endColorstr='#f171ab');
  222. }
  223. .pink:hover {
  224. background: #d57ea5;
  225. background: -webkit-gradient(linear, left top, left bottom, from(#f4aacb), to(#e86ca4));
  226. background: -moz-linear-gradient(top, #f4aacb, #e86ca4);
  227. filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#f4aacb', endColorstr='#e86ca4');
  228. }
  229. .pink:active {
  230. color: #f3c3d9;
  231. background: -webkit-gradient(linear, left top, left bottom, from(#f171ab), to(#feb1d3));
  232. background: -moz-linear-gradient(top, #f171ab, #feb1d3);
  233. filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#f171ab', endColorstr='#feb1d3');
  234. }

Report this snippet Tweet<iframe style="line-height: 1.22em; border-style: none; overflow: hidden; width: 100px; height: 21px;" src="http://www.facebook.com/plugins/like.php?href&send=false&layout=button_count&width=100&show_faces=false&action=like&colorscheme=light&font&height=21&appId=199515416764139" frameborder="0" scrolling="no"></iframe>

Related Snippets


  1. Create gradient buttons using css
  2. CSS Gradient
  3. CSS3 Gradient Background
  4. Pure CSS3 Buttons
  5. Kickapps: use jQuery & CSS to hide MYRSS & MYLINKS buttons in member profile edit pages
  6. Crossbrowser CSS Gradient
  7. CSS Buttons - horizontal nav bar w/out images
  8. One pixel, pure CSS2 rounded buttons
  9. CSS - Adding a gradient – linear-gradient
  10. CSS3 Button with hover over, shadowing, and gradient

评论(1)

  1. #1 楼 · coosummer · 2015-11-11 17:59

    推荐使用http://buttoncssgenerator.com ,可以生成各种效果的按钮css,包括圆角、渐进颜色、阴影,并兼容各大主流浏览器

评论功能维护中,当前仅展示历史评论。