Paulund

How To Build A Pricing Table With CSS3 Animation

Quite often I’m given a PSD and asked to convert this into HTML/CSS for the graphic designer. I was given a PSD which was a pricing table and realised that there are ways to improve the look of this just by using CSS. When I put this suggestion forward to the graphic designer they said no and want to me to just make the table and everything else was going to be images.

Just to prove I was right I am writing this tutorial to turn the below PSD image into HTML and pure CSS, this is not the PSD I was given but it’s a good example.

Pricing table

This is just a simple PSD of a pricing table but the middle column is larger than the others. I thought this would be ideal to use CSS animation to scale the current column the mouse is hovering over.

This tutorial is will teach you how to create this pricing table with the CSS scaling effects, view the demo to see what we will be making.

Demo

The HTML

The HTML for the table is in fact not a table this can easily be done by using a table but I prefer not working with tables. The data that needs to be displayed can be better organised by using a list this is because the data can to split into columns to be displayed to the visitor.

  • First we create a div which will hold the lists.
  • Create 5 lists for different columns.
  • Enter the column data.
<div class="pricing_table">
		<ul>
			<li>Standard</li>
			<li>&pound;20</li>
			<li>Perfect for those getting started with our app.</li>
			<li>15 Projects</li>
			<li>5GB Storage</li>
			<li>Unlimited Users</li>
			<li>No Time Tracking</li>
			<li>Enchaned Security</li>
			<li></li>
			<li><a href="" class="buy_now">Buy Now</a></li>
		</ul>

		<ul>
			<li>Premium</li>
			<li>&pound;60</li>
			<li>Perfect for those getting started with our app.</li>
			<li>15 Projects</li>
			<li>5GB Storage</li>
			<li>Unlimited Users</li>
			<li>No Time Tracking</li>
			<li>Enchaned Security</li>
			<li></li>
			<li><a href="" class="buy_now">Buy Now</a></li>
		</ul>

		<ul>
			<li>Professional</li>
			<li>&pound;80</li>
			<li>Perfect for those getting started with our app.</li>
			<li>15 Projects</li>
			<li>5GB Storage</li>
			<li>Unlimited Users</li>
			<li>No Time Tracking</li>
			<li>Enchaned Security</li>
			<li></li>
			<li><a href="" class="buy_now">Buy Now</a></li>
		</ul>

		<ul>
			<li>Plus</li>
			<li>&pound;100</li>
			<li>Perfect for those getting started with our app.</li>
			<li>15 Projects</li>
			<li>5GB Storage</li>
			<li>Unlimited Users</li>
			<li>No Time Tracking</li>
			<li>Enchaned Security</li>
			<li></li>
			<li><a href="" class="buy_now">Buy Now</a></li>
		</ul>

		<ul>
			<li>Maximum</li>
			<li>&pound;120</li>
			<li>Perfect for those getting started with our app.</li>
			<li>15 Projects</li>
			<li>5GB Storage</li>
			<li>Unlimited Users</li>
			<li>No Time Tracking</li>
			<li>Enchaned Security</li>
			<li></li>
			<li><a href="" class="buy_now">Buy Now</a></li>
		</ul>
</div>

The CSS

First we are going to write the style for the outline of the whole table. This can easily be done using the CSS outline property, then we need to curve the border by using the border-radius property.

Complete this by using the following CSS.

.pricing_table {
	border:1px solid #c4cbcc;
	border-radius:4px;
	-moz-border-radius:4px;
	-webkit-border-radius:4px;
	outline:7px solid #f2f3f3;
	float:left;
}

Style the Price Table Columns

Now we have the outline of the price table lets create the columns from the list items. Do the following to the lists:

  • First remove the list styles
  • Make the lists float left
  • Create the width of the each column
  • Make sure there is no margin for the lists
  • Add a border around the whole list
  • Add some padding inside the padding
  • Make the text align to the center
  • Make sure that the background colour is white

Here is the CSS for the above.

.pricing_table ul {
	list-style:none;
	float:left;
	width:147px;
	margin:0;
	border:1px solid #f2f3f3;
	padding:5px;
	text-align:center;
	background-color:#FFF;
}

Style The Hover Event

Looking back at the PSD image we had a column which was larger than the other columns, we are going to achieve this look by scaling the column up when the mouse is over the column. For this effect we can just use the :hover event on the list.

To achieve the the scaling of the column we need to use a CSS3 feature called transform.

  • Transform the column with a scale of 1.1, therefore increase the size by 10%.
  • Set a box shadow to make it look as if the box is coming out at you.
  • Change the cursor to be a pointer.

Copy the following CSS to achieve the column scaling.

.pricing_table ul:hover {
	-webkit-transform: scale(1.1);
  	-moz-transform: scale(1.1);
  	-o-transform: scale(1.1);
  	-moz-box-shadow:3px 5px 7px rgba(0,0,0,.7);
  	-webkit-box-shadow: 3px 5px 7px rgba(0,0,0,.7);
  	box-shadow:3px 5px 7px rgba(0,0,0,.7);
	cursor:pointer;
}

Styling Each List Item

Each list item needs to have padding and a border on the bottom, use the following CSS to achieve this styling.

.pricing_table ul li {
	border-bottom:1px dashed #cfd2d2;
	padding:10px 0;
}

Styling The Rows

Almost every row in the pricing table has a different styling a good thing about the CSS3 we are using is that you can change any row you want just by using CSS.

  • The first row needs to be larger font and with a bold weight.
  • On the second row we need a darker background colour.
  • With the 3rd row we need a smaller font but the weight needs to be bold.
  • With the remaining rows we need to set the font size to be 14pixels.
  • On the last row we are going to add a link which will be the sign up now button call to action.

Use the following CSS to achieve this look.

.pricing_table ul li:first-child {
	font-size:18px;
	font-weight:bold;
}
.pricing_table ul li:nth-child(2) {
	background:#fbfbfb;
}
.pricing_table ul li:nth-child(3) {
	font-size:12px;
	font-weight:bold;
}
.pricing_table ul li:nth-child(n+4) {
	font-size:14px;
}
.pricing_table ul li:last-child a {
	border-radius:10px;
	-moz-border-radius:10px;
	-webkit-border-radius:10px;
	border:1px solid #c4cbcc;
	padding:10px;
	margin:5px 0;
	background: #e5e696; /* Old browsers */
	background: -moz-linear-gradient(top, #e5e696 0%, #d1d360 100%); /* FF3.6+ */
	background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#e5e696), color-stop(100%,#d1d360)); /* Chrome,Safari4+ */
	background: -webkit-linear-gradient(top, #e5e696 0%,#d1d360 100%); /* Chrome10+,Safari5.1+ */
	background: -o-linear-gradient(top, #e5e696 0%,#d1d360 100%); /* Opera11.10+ */
	background: -ms-linear-gradient(top, #e5e696 0%,#d1d360 100%); /* IE10+ */
	filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#e5e696', endColorstr='#d1d360',GradientType=0 ); /* IE6-9 */
	background: linear-gradient(top, #e5e696 0%,#d1d360 100%); /* W3C */
	color:#000;
	font-style:italic;
	display:block;
}

Like this image, want to download the full PSD? Get the PSD from premium pixels freebies.

View the demo to make sure that your pricing table is the same. If you followed the tutorial you should have the same.

Demo

Rockstar Wordpress Designer

Writen By Paul

Paulund is a website dedicated to writing tutorials and code snippets about Web Development, the main subjects are PHP, Wordpress, jQuery, CSS3 and HTML5.

Website: http://www.paulund.co.uk

Feedback

Anything to add?

  • david

    this does not seem to work in internet explorer 9. any ideas? thanks in advance

    • http://www.paulund.co.uk Paul

      There are some css3 things which IE9 can’t do I don’t know exactly what but if you use Firefox or Chrome it should work perfectly well.

      • david

        yes i use firefox just was looking for complete cross browser compatibility. thanks though still good work

        • http://www.paulund.co.uk Paul

          hi David did you find out anymore about the compatibility issues?

          • david

            no still working on it

  • Pingback: How To Build A Pricing Table With CSS3 Animation

  • http://twitter.com/JoelBesada Joel Besada

    Cool, but I don’t see any animations on the pricing table. CSS transforms is not the same as CSS transitions (i.e. animations).

  • adam

    the typeface on your website renders weird at the size you have it for articles. I’m on Chrome/Win7

  • http://www.logoguru.co.uk/ Sam Anderson

    i have use this codes as you given to me but i am facing problem that i have created the table in 1st step but inner content of a table bounds out in alignment. What should i do to fix it?

    • http://www.paulund.co.uk Paul

      Not sure I can help without seeing whats wrong so the only thing I can suggest is to try copying the code again you might of missed something.

  • Pingback: CSS3 by ntzog - Pearltrees

  • http://www.BriteRise.com/ Jason Davis

    Perfect. I love it and it worked flawlessly. Set up a 3 column pricing grid with beautiful style in 20 minutes. Thank you Thank you Thank you.

    Check it out on WordPress Blogs

    • http://www.paulund.co.uk/ Paul

      Nice one looks awesome good work.

      • http://www.BriteRise.com/ Jason Davis

        Thanks again for the wonderful snippet and reply.

        • http://www.paulund.co.uk/ Paul

          Your Welcome Jason