{"id":257,"date":"2014-05-11T00:58:32","date_gmt":"2014-05-11T00:58:32","guid":{"rendered":"http:\/\/www.cssportal.com\/blog\/?p=257"},"modified":"2024-02-28T23:28:58","modified_gmt":"2024-02-28T23:28:58","slug":"4-cool-css-buttons","status":"publish","type":"post","link":"https:\/\/www.cssportal.com\/blog\/4-cool-css-buttons\/","title":{"rendered":"4 Cool CSS Buttons"},"content":{"rendered":"<p>Today we are going to show you how to give your CSS buttons a bit more of a fancier design. Using simple CSS we can make our buttons stand out from ordinary buttons, giving them that extra style we want for our webpages.<br \/>\n<!--more--><br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-258\" src=\"http:\/\/www.cssportal.com\/blog\/wp-content\/uploads\/2014\/05\/button.png\" alt=\"CSS Buttons\" width=\"761\" height=\"99\" \/><br \/>\nWe&#8217;ll start this tutorial by looking at the HTML code required to display these new buttons.<\/p>\n<pre class=\"language-html\"><code>&lt;button class=\"newbutton\"&gt;New Button&lt;\/button&gt;\r\n&lt;button class=\"newbutton red\"&gt;New Button&lt;\/button&gt;\r\n&lt;button class=\"newbutton green\"&gt;New Button&lt;\/button&gt;\r\n&lt;button class=\"newbutton black\"&gt;New Button&lt;\/button&gt;<\/code><\/pre>\n<p>As you can see, we are just using a class of &#8216;newbutton&#8217; to create this effect, plus on the last three lines we have added a new color to our buttons.<\/p>\n<p>Now the fun begins, here is the CSS required to style our new buttons, we&#8217;ll look at some of the properties and what they are used for below the code.<\/p>\n<pre class=\"language-css\"><code>.newbutton {\r\n  height: 38px;\r\n  text-align: center;\r\n  border-radius: 28px;\r\n  background: #13b5ea;\r\n  background: -moz-linear-gradient(top, #13b5ea, #0f91bb);\r\n  background: -webkit-gradient(linear, 0 0, 0 100%, from(#13b5ea), to(#0f91bb));\r\n  background: -webkit-linear-gradient(top, #13b5ea, #0f91bb);\r\n  background: -o-linear-gradient(top, #13b5ea, #0f91bb);\r\n  background: linear-gradient(to bottom, #13b5ea, #0f91bb);\r\n  -webkit-transition: 0.5s;\r\n  -moz-transition: 0.5s;\r\n  -o-transition: 0.5s;\r\n  transition: 0.5s;\r\n  color: #ffffff;\r\n  text-decoration: none;\r\n  font-size: 13px;\r\n  line-height: 28px;\r\n  margin: 5px 0;\r\n  padding: 0 20px;\r\n  border: 5px solid #c8e6f0;\r\n}\r\n<\/code><\/pre>\n<p><span class=\"code\">height<\/span> &#8211; This property is going to set the height of our button to 38px.<br \/>\n<span class=\"code\">text-align<\/span> &#8211; Here we want our text to align in the center of the button.<br \/>\n<span class=\"code\">border-radius<\/span> &#8211; You can change this value to alter the radius of the button.<br \/>\n<span class=\"code\">background<\/span> &#8211; This will set the background of the button, and if supported by the user browser, will also set the background gradient.<br \/>\n<span class=\"code\">transition<\/span> &#8211; This property is used for our hover effect, code is below.<br \/>\n<span class=\"code\">padding<\/span> &#8211; Using &#8216;0 20px&#8217; will give our button padding at the left and right of 20px. Top and bottom is 0.<br \/>\n<span class=\"code\">border<\/span> &#8211; Gives the button a border of 5px<\/p>\n<p>The following CSS code is used to change the color of our button, you could easily add further colors by changing the hex values.<\/p>\n<pre class=\"language-css\"><code>.newbutton.red {\r\n  background: #B33333;\r\n  background: -moz-linear-gradient(top, #B33333, #800000);\r\n  background: -webkit-gradient(linear, 0 0, 0 100%, from(#B33333), to(#800000));\r\n  background: -webkit-linear-gradient(top, #B33333, #800000);\r\n  background: -o-linear-gradient(top, #B33333, #800000);\r\n  background: linear-gradient(to bottom, #B33333, #800000);\r\n  border: 5px solid #FFCCCC;\r\n}\r\n.newbutton.green {\r\n  background: #33B3B3;\r\n  background: -moz-linear-gradient(top, #33B3B3, #008080);\r\n  background: -webkit-gradient(linear, 0 0, 0 100%, from(#33B3B3), to(#008080));\r\n  background: -webkit-linear-gradient(top, #33B3B3, #008080);\r\n  background: -o-linear-gradient(top, #33B3B3, #008080);\r\n  background: linear-gradient(to bottom, #33B3B3, #008080);\r\n  border: 5px solid #CCFFFF;\r\n}\r\n.newbutton.black {\r\n  background: #7F7F7F;\r\n  background: -moz-linear-gradient(top, #7F7F7F, #333333);\r\n  background: -webkit-gradient(linear, 0 0, 0 100%, from(#7F7F7F), to(#333333));\r\n  background: -webkit-linear-gradient(top, #7F7F7F, #333333);\r\n  background: -o-linear-gradient(top, #7F7F7F, #333333);\r\n  background: linear-gradient(to bottom, #7F7F7F, #333333);\r\n  border: 5px solid #CCCCCC;\r\n}\r\n<\/code><\/pre>\n<p>Lastly we have the CSS code that will be used when will hover over the button.<\/p>\n<pre class=\"language-css\"><code>.newbutton:hover {\r\n  -webkit-box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);\r\n  -moz-box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);\r\n  box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);\r\n  border-color: #ffffff;\r\n}\r\n<\/code><\/pre>\n<p>With the code above, when the user hovers over our new button, we&#8217;ll be changing our border to white plus we&#8217;ll be giving our button a box shadow of black with a blur of 10px plus to give a nice soft effect, the color has an opacity of 20%.<\/p>\n<p>That&#8217;s it for this post, as usual here is a link to a demo of the project where can play with the values to see what effects it will have on the final look of the buttons.<\/p>\n<p><a class=\"btn btn-primary\" href=\"https:\/\/www.cssportal.com\/tryit\/index.php?file=blog\/css-buttons\" target=\"_blank\" rel=\"noopener\">Demo<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Today we are going to show you how to give your CSS buttons a bit more of a fancier design. Using simple CSS we can make our buttons stand out from ordinary buttons, giving them that extra style we want for our webpages.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-257","post","type-post","status-publish","format-standard","hentry","category-css","wpautop"],"_links":{"self":[{"href":"https:\/\/www.cssportal.com\/blog\/wp-json\/wp\/v2\/posts\/257","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.cssportal.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.cssportal.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.cssportal.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.cssportal.com\/blog\/wp-json\/wp\/v2\/comments?post=257"}],"version-history":[{"count":4,"href":"https:\/\/www.cssportal.com\/blog\/wp-json\/wp\/v2\/posts\/257\/revisions"}],"predecessor-version":[{"id":549,"href":"https:\/\/www.cssportal.com\/blog\/wp-json\/wp\/v2\/posts\/257\/revisions\/549"}],"wp:attachment":[{"href":"https:\/\/www.cssportal.com\/blog\/wp-json\/wp\/v2\/media?parent=257"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.cssportal.com\/blog\/wp-json\/wp\/v2\/categories?post=257"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.cssportal.com\/blog\/wp-json\/wp\/v2\/tags?post=257"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}