In this article we continue with our look at CSS3 buttons and gradients. You will see some simple coding examples and we will also look at several software programs you can use to create CSS3 effects, quickly. These programs also include vendor prefixes, as well, which will save you time.
CSS3 Gradients
CSS gradients allow to you display smooth transitions between two or more specified colors. Now, you no longer need to use images for these effects, which reduces download time and bandwidth demands. There are two types of gradients you can use. These are linear (linear-gradient) and radial (radial-gradient).
A simple example is the gradient below, which runs vertically.
Color stops have a specific color at that location, which can be a percentage or absolute length. You can add as many color stops as you wish. As an example of how that would work, 0% would be the starting point and 100% the ending point. Here is an example with three colors:
<!doctype html>
<html>
<head>
<meta charset=”utf-8″>
<title>Untitled Document</title>
<style>
#grad1 {
height:200px;
background: linear-gradient(to right, red , green, blue);
}
</style>
</head>
<body>
<div id=”grad1″></div>
</body>
</html>
The completed gradient.
Here is an example which makes use of transparency. Note the representation of the colors (rgba – red, green, blue, alpha – transparency – 255,0,0,.8).
One thing which will rapidly become apparent is many buttons make use of gradients and of boxes and borders. All of these in combination allow you to create some great effects and all without the need to use images.
Here is a simple CSS3 button with a solid background:
This button is about as bare bones as you can get. Fortunately you can spice things up by adding a gradient, experimenting with the border and adding a drop shadow. Here is the code:
You can go much further than what is available here, but it becomes a bit difficult because of not being able to see the effect until the code is rendered. A better way is to make use of software programs which gives you image previews as you make changes. Some of these include CSS3 effects as part of the interface; others are standalone programs which are web-based or can be downloaded and run on your computer.
One software provider which creates many standalone CSS3 programs is Blumental Software. Of these products, I recommend the Easy Button and Menu Maker. Note that these are paid programs.
Another useful tool is the web-based Easy CSS3 Generator. This one tool gives you many options which are: Button Generator, Border Radius, Box Shadow, Text Shadow and CSS3 Gradients. This program is free to use.
For fast gradients, check out the Ultimate CSS Gradient Generator by Colorzilla. This is a web-based program and is free.
As you see by the screen shot, this program is for creating CSS3 gradients, only. It offers a number of presets or you can quickly create your own, including transparency. You can then copy the code directly for use in your layouts.
For creating layouts, check out Adobe Dreamweaver CC. One of the many great features of this program is it allows you to create fluid layouts. This gives you a starting point for creating flexible CSS layouts for the desktop, tablets and mobile devices.
Adobe Edge Reflow CC is part of the Creative Cloud package. If you create a layout in Photoshop CC, you can make use of the Generator plugin and export your layout to Edge Reflow CC and use that program to stylize your layout even further with a wide variety of CSS3 tools.
Conclusion
As you can see, there are several options to create CSS3 effects and styling. One option is to code everything by hand; another option is to make use of software programs. A third option is to use a software program, create an effect which is close to what you desire then refine it by hand coding.
The original home of HTML tutorials. HTMLGoodies is a website dedicated to publishing tutorials that cover every aspect of being a web developer. We cover programming and web development tutorials on languages and technologies such as HTML, JavaScript, and CSS. In addition, our articles cover web frameworks like Angular and React.JS, as well as popular Content Management Systems (CMS) that include WordPress, Drupal, and Joomla. Website development platforms like Shopify, Squarespace, and Wix are also featured. Topics related to solid web design and Internet Marketing also find a home on HTMLGoodies, as we discuss UX/UI Design, Search Engine Optimization (SEO), and web dev best practices.
Advertiser Disclosure: Some of the products that appear on
this site are from companies from which TechnologyAdvice
receives compensation. This compensation may impact how and
where products appear on this site including, for example,
the order in which they appear. TechnologyAdvice does not
include all companies or all types of products available in
the marketplace.