css responsive table

How you can create a table that fits on every screen size? Solution: CSS Responsive Table With HTML & jQuery, A CSS HTML Table Design.

I am sure that you know about HTML tables. Tables can use on may places on the web like in backend, frontend pricing table, comparing table, etc. If you are learning HTML & CSS or you have learned before, then you probably know that table in HTML is an important command.

Today you will learn to create an attractive & responsive table design with great UI. You can use it on your website or your current project because this is responsive & functional also. It’s a basic <td> <th> based table, but the CSS & jQuery make this unique. This table has a different layout & function on small screens.

So, Today I am sharing CSS Responsive Table With HTML & jQuery. A pure HTML & CSS table but the jQuery used for responsive functionality. This table has a toggle function for a small screen, that’s why I am using jQuery. Otherwise, all the elements style & designs are in CSS.

If you are thinking now how this table actually is, then see the preview given below.

Preview Of jQuery HTML Table

See this video preview to getting an idea of how this responsive table looks like.

Now you can see this visually. If you like this, then get the source code of its.

You May Also Like:

CSS Responsive Table Source Code

Before sharing source code, let’s talk about this. I created a table using <tr> <th> <td>, but I add an extra <th> in every section with a class name. In extra <th> section I give class name responsive-toggle, It looks like this class= "responsive-toggle". I gave this name because this extra part is for responsive design or small screen.

In normal or large screen I put display: none to this extra th part. This part is handling jQuery, turn on the display of this extra part on the small screen with a toggle feature. Basically, jQuery hide the main <TH> & show the extra <TH> on small screens. For creating it responsive I gave CSS @media query with many conditions.

As you can see on the preview, there is color fill on the table in even numbers of td. I the even numbers of rows using table tr:nth-of-type(even) CSS property. I have used a google font named Lato in this table design, for creating this good looking. There is a small part of JS because we are using jQuery.

Left other things you will understand after getting the codes. I can’t explain properly in writing there, when will see codes then you will understand how it works. If you got any trouble to understand you can ask me in the comment section. For creating this Responsive Table you have to create 3 files. First for HTML, second for CSS, & last for JavaScript or jQuery.

Follow the steps to creating this without any error.

index.html

Create an HTML file named ‘index.html‘ and put these codes given below.

style.css

Now create a CSS file named ‘style.css‘ and put these codes.

function.js

The final step, Create a JS file named ‘function.js‘ and put the codes.

That’s It. Now you have successfully created CSS Responsive Table With HTML & jQuery. If you have any doubt or question comment down below.

Thanks For Visiting, Keep Visiting.

6 COMMENTS

LEAVE A REPLY

Please enter your comment!
Please enter your name here