We see everyday pricing tables on different websites for e.g. basic pricing or free plan, advanced or pro or medium pricing and premium or business pricing. Generally those tables contain 3 columns pricing but some of them contain 2, 4 or even 5 columns pricing based on their user needs.
I am going to discuss about 3 columns pricing tables using CSS and you can easily make it to 2 to 5 pricing tables from that code. So, let’s start with the HTML as usual.
In the HTML code above, I have 3 columns and all of them are in 3 different containers element div with class=allColumns. I am going to set equal width in CSS for all of them.
Inside that container, I have added unordered list and added a class=singleColumn which will give different style to it. After that I have different list items but with unique classes so that each list items will have their own styles. At the end I’ve added Sign Up link as well but I haven’t specified any link in href for this example.
All of the code is same for all 3 columns except the background-color of header and buttons as I wanted to show users different colors for different plans.
I want the whole table to look like the image at the top of this page.
Let’s add CSS style to make the pricing table like the image above at the top.
In the CSS code above, there are some basic CSS properties I have used. I am keeping body color as red to match it with Todoist theme and Logo color. Now, as I have discussed in the HTML code above, I am keeping same width for all 3 columns which is styled in the class=allColumns. We need float left as we need the fist plan, which is basic to be shown left then gradually increases the plans. padding for space between those columns and as you can see width is 33.3% making it equal for all columns.
Next, I am styling single column class. Now this class we have assigned into a list elements so we need to get rid of those dots in unordered lists. For that we need list-style-type value set as none. Then there is a border which you can choose whether to add or not. The properties margin and padding will make it look really organised but you can choose not to use that as well. The next one is transition which I am using for hover event on those columns. I am setting box-shadow property on mouse hover event and adding a smooth transition to it. Again, it’s optional.
Next, I want other list items, their headers, buttons and links in different background-color and different styles as well. So, I have set up those different styles using different classes. It’s not mandatory.
Lastly, I have added media rule to set each columns width as 100% when the screen gets smaller fort e.g. any mobile device screens will less than 600px.