YogeshChauhan . com

Create a responsive pricing table using simple HTML and CSS

in CSS & HTML on August 7, 2019

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.

HTML

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.

CSS

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.

amazon

Most Read

#1 How to check if radio button is checked or not using JavaScript? #2 Solution to “TypeError: ‘x’ is not iterable” in Angular 9 #3 How to add Read More Read Less Button using JavaScript? #4 How to uninstall Cocoapods from the Mac OS? #5 How to Use SQL MAX() Function with Dates? #6 PHP Login System using PDO Part 1: Create User Registration Page

Recently Posted

Jun 16 What are Stored Procedures for SQL Server? Jun 16 What are Class Constants in PHP? Jun 15 A short basic guide on states in React Jun 15 How to define constants in PHP? Jun 15 How to define visibility for a property in PHP? Jun 15 How to use @if and @else in SCSS?

You might also like these

How to modify navigation menus in WordPress?WordPressUnderstanding the confusing and handy “This” keyword in JavaScriptJavaScriptHow to render lists inside a component in React?ReactSocial Media Colors: LESS VariablesMiscHow to create a simple slider with CSS and jQuery?CSSThe fundamental difference between HAVING and WHERE clauses in PostgresPostgres