Projects

Designing an Advanced Pricing Table with CSS Grid

Introduction to Advanced Pricing Tables

Welcome to Designing an Advanced Pricing Table with CSS Grid!

In this project, we'll create a fully responsive pricing table using CSS Grid. A well-designed pricing table is essential for showcasing different pricing plans on a website, ensuring that it looks great on various devices, from desktops to mobile phones.

Here's what we'll cover in this tutorial:

By the end of this project, you'll have a fully functional and responsive pricing table. Let's get started by setting up our project files!

Setting Up Your Workspace

Creating Your Project Folder and Files

Before we start coding, let's set up a workspace for our project:

Step 1: Create Your Project Folder

Think of this folder like a container where we'll keep all our project files - just like having a special drawer for your art supplies!

Step 2: Get Your Text Editor Ready

A text editor is like your crafting tool - it's where we'll write our code. We recommend Visual Studio Code because it's free and beginner-friendly!

  1. Download Visual Studio Code from code.visualstudio.com if you haven't already
  2. Install it on your computer
  3. Open VS Code and drag your "advanced-pricing-table" folder into the window

Step 3: Create Your Project Files

We need two special files - think of them as two pieces of paper where we'll write different things:

To create these files:

  1. Click "New File" in VS Code
  2. Save it as "index.html"
  3. Create another new file
  4. Save it as "styles.css"

🎯 Success Check: At this point, you should have:

👉 Need Help? If something's not working, try closing VS Code and opening it again, or create the files using the "File → New File" menu.

Setting Up the HTML Structure

Creating the Pricing Table HTML

Before we dive into CSS, let's set up the HTML structure for our pricing table:

  1. 1. Open "index.html": Open your "index.html" file in your code editor.
  2. 2. Add the Pricing Table HTML: Copy and paste the following code into your "index.html" file:
    <!DOCTYPE html>
    <html lang="en">
    <head>
      <meta charset="UTF-8">
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      <title>Advanced Pricing Table</title>
      <link rel="stylesheet" href="styles.css">
    </head>
    <body>
      <div class="pricing-table">
        <div class="plan">
          <div class="plan-header">
            <h3>Basic</h3>
            <span class="price">$9.99</span>
          </div>
          <ul class="plan-features">
            <li>10 GB Storage</li>
            <li>100 GB Bandwidth</li>
            <li>2 Domains</li>
            <li>Email Support</li>
          </ul>
          <button>Sign Up</button>
        </div>
        <div class="plan">
          <div class="plan-header">
            <h3>Pro</h3>
            <span class="price">$19.99</span>
          </div>
          <ul class="plan-features">
            <li>50 GB Storage</li>
            <li>500 GB Bandwidth</li>
            <li>10 Domains</li>
            <li>Priority Email Support</li>
          </ul>
          <button>Sign Up</button>
        </div>
        <div class="plan">
          <div class="plan-header">
            <h3>Premium</h3>
            <span class="price">$29.99</span>
          </div>
          <ul class="plan-features">
            <li>100 GB Storage</li>
            <li>1 TB Bandwidth</li>
            <li>Unlimited Domains</li>
            <li>24/7 Phone Support</li>
          </ul>
          <button>Sign Up</button>
        </div>
      </div>
    </body>
    </html>

Let's understand the HTML structure:

Save your "index.html" file. Now we have the basic HTML structure in place. In the next step, we'll start applying CSS styles to our pricing table.

Styling the Body

Styling the Body

Let's start by styling the body of our HTML document to ensure a consistent and clean layout.

  1. 1. Open "styles.css": Open the "styles.css" file in your code editor.
  2. 2. Add Body Styles: Copy and paste the following CSS code into your "styles.css" file:
    body {
      font-family: Arial, sans-serif;
      margin: 0;
      padding: 0;
      box-sizing: border-box;
      background-color: #f4f4f4;
      display: flex;
      justify-content: center;
      align-items: center;
      height: 100vh;
    }

Let's understand the CSS rules we just added:

Save your "styles.css" file. Now, if you open "index.html" in a web browser, you'll see the basic layout applied to your page.

In the next step, we'll style the pricing table container.

Styling the Pricing Table Container

Styling the Pricing Table Container

Now, let's style the pricing table container to give it a clean and modern look.

  1. 1. Open "styles.css": Open the "styles.css" file in your code editor.
  2. 2. Add Pricing Table Container Styles: Copy and paste the following CSS code into your "styles.css" file:
    .pricing-table {
      display: grid;
      grid-template-columns: repeat(3, 1fr);
      gap: 20px;
      width: 90%;
      max-width: 1200px;
      padding: 20px;
      background-color: #fff;
      border-radius: 10px;
      box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    }

Let's understand the CSS rules we just added:

Save your "styles.css" file. Now, if you open "index.html" in a web browser, you'll see the styled pricing table container.

In the next step, we'll style the individual pricing plans.

Styling the Pricing Plans

Styling the Pricing Plans

Now, let's style the individual pricing plans to make them visually appealing and easy to read.

  1. 1. Open "styles.css": Open the "styles.css" file in your code editor.
  2. 2. Add Pricing Plan Styles: Copy and paste the following CSS code into your "styles.css" file:
    .plan {
      background-color: #fff;
      border-radius: 10px;
      padding: 20px;
      box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
      text-align: center;
    }
    
    .plan-header {
      background-color: #007bff;
      color: #fff;
      padding: 20px;
      border-radius: 10px 10px 0 0;
      margin-bottom: 20px;
    }
    
    .plan-header h3 {
      margin: 0;
      font-size: 1.5rem;
    }
    
    .plan-header .price {
      font-size: 2rem;
      font-weight: bold;
    }
    
    .plan-features {
      list-style: none;
      padding: 0;
      margin: 0 0 20px;
    }
    
    .plan-features li {
      padding: 10px 0;
      border-bottom: 1px solid #ddd;
      font-size: 1rem;
      color: #555;
    }
    
    .plan-features li:last-child {
      border-bottom: none;
    }
    
    .plan button {
      background-color: #007bff;
      color: #fff;
      border: none;
      padding: 10px 20px;
      border-radius: 5px;
      cursor: pointer;
      font-size: 1rem;
      transition: background-color 0.3s ease;
    }
    
    .plan button:hover {
      background-color: #0056b3;
    }

Let's understand the CSS rules we just added:

Save your "styles.css" file. Now, if you open "index.html" in a web browser, you'll see the styled pricing plans.

In the next step, we'll make the pricing table responsive for different screen sizes.

Making the Pricing Table Responsive

Making the Pricing Table Responsive

Let's ensure our pricing table looks great on various devices by adding responsive design using CSS media queries.

  1. 1. Open "styles.css": Open the "styles.css" file in your code editor.
  2. 2. Add Responsive Design Styles: Copy and paste the following CSS code into your "styles.css" file:
    @media (max-width: 768px) {
      .pricing-table {
        grid-template-columns: 1fr;
      }
    
      .plan {
        margin-bottom: 20px;
      }
    }

Let's understand the CSS rules we just added:

Save your "styles.css" file. Now, if you resize your browser window or view the pricing table on different devices, you'll see the layout adapt to different screen sizes.

In the next step, we'll add final touches to the pricing table.

Adding Final Touches

Adding Final Touches

Let's add the final touches to our responsive pricing table to ensure it is fully functional and visually appealing.

  1. 1. Open "styles.css": Open the "styles.css" file in your code editor.
  2. 2. Add Final Touches: Copy and paste the following CSS code into your "styles.css" file:
    .plan:hover {
      transform: scale(1.05);
      transition: transform 0.3s ease;
    }

Let's understand the CSS rules we just added:

Save your "styles.css" file. Now, if you open "index.html" in a web browser, you'll see the final touches in action.

Congratulations! You've completed the CSS project, "Design an Advanced Pricing Table." You've learned how to create a fully responsive pricing table using HTML and CSS.

Feel free to continue customizing your pricing table and exploring more CSS techniques. Happy coding!