Styling Your Pricing Table with a Unique Bootstrap Card Design

Today, I've been working on the bootstrap card lesson and followed along with my teacher. However, the grid markup effect isn't functioning as expected.

Initially, I doubted myself and thought I had inputted something wrong, but upon closer inspection, that wasn't the case.

The requirement was to create the first two containers with 50% padding (PAD) and the third container with 100% width.

I assigned to the first two containers and to the third.

The code I used mirrors what was taught in the lesson, yet the pricing table isn't displaying correctly.

Could you please provide advice on what steps I should take next?

Take a look at the code I've entered below in my Codeply snippet:

https://i.sstatic.net/lOAPe.png

https://i.sstatic.net/ZYjSk.png

<!DOCTYPE html>
<html>

<head>
  <meta charset="utf-8">
  <title>TinDog</title>
  <!-- Google Font -->
  <link href="https://fonts.googleapis.com/css2?family=Montserrat:wght@100;400;700&family=Ubuntu:wght@300;400;700&display=swap" rel="stylesheet">

  <link rel="preconnect" href="https://fonts.gstatic.com">

  <!-- css stylesheet -->
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
  <link rel="stylesheet" href="css/styles.css">
  <!-- fontawesome -->
  <script src="https://kit.fontawesome.com/e2fafd992e.js" crossorigin="anonymous"></script>

  <!-- Bootstrap Script -->
  <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>

<body>


<!-- Pricing -->

  <section id="pricing">

    <h2>A Plan for Every Dog's Needs</h2>
    <p>Simple and affordable price plans for your and your dog.</p>

    <div class="row">
      <div class="col-lg-4 col-md-6">

        <div class="card">
          <div class="card-header">
            <h3>Chihuahua</h3>
          </div>
        </div>
      </div>


      <div class="card-body">
        <h2>Free</h2>
        <p>5 Matches Per Day</p>
        <p>10 Messages Per Day</p>
        <p>Unlimited App Usage</p>
        <button type="button">Sign Up</button>

      </div>
    </div>

    <div class="col-lg-4 col-md-6">
      <div class="card">
        <div class="card-header">
          <h3>Labrador</h3>
        </div>

        <div class="card-body">
          <h2>$49 / mo</h2>
          <p>Unlimited Matches</p>
          <p>Unlimited Messages</p>
          <p>Unlimited App Usage</p>
          <button type="button">Sign Up</button>

        </div>
      </div>
    </div>

    <div class="col-lg-4">
      <div class="card">
        <div class="card-header">
          <h3>Mastiff</h3>
        </div>

        <div class="card-body">
          <h2>$99 / mo</h2>
          <p>Priority Listing</p>
          <p>Unlimited Matches</p>
          <p>Unlimited Messages</p>
          <p>Unlimited App Usage</p>
          <button type="button">Sign Up</button>
        </div>
      </div>
    </div>
    </div>
    </div>

  </section>

</body>

Answer №1

You may be experiencing an issue because your first card body div is located outside of the card div.

  <section id="pricing">

    <h2>A Plan for Every Dog's Needs</h2>
    <p>Discover simple and affordable price plans tailored to you and your canine companion.</p>

    <div class="row">
      <div class="col-lg-4 col-md-6">

        <div class="card">
          <div class="card-header">
            <h3>Chihuahua</h3>
          </div>
          <div class="card-body">
            <h2>Free</h2>
            <p>Enjoy 5 Matches Per Day</p>
            <p>Receive 10 Messages Per Day</p>
            <p>Unlimited App Usage Included</p>
            <button type="button">Sign Up Now</button>
          </div>
        </div>
      </div>


      


    <div class="col-lg-4 col-md-6">
      <div class="card">
        <div class="card-header">
          <h3>Labrador</h3>
        </div>

        <div class="card-body">
          <h2>$49 / month</h2>
          <p>Access Unlimited Matches</p>
          <p>Send Unlimited Messages</p>
          <p>Enjoy Unlimited App Usage</p>
          <button type="button">Get Started</button>

        </div>
      </div>
    </div>

    <div class="col-lg-4">
      <div class="card">
        <div class="card-header">
          <h3>Mastiff</h3>
        </div>

        <div class="card-body">
          <h2>$99 per month</h2>
          <p>Priority Listing Feature</p>
          <p>Unrestricted Matches</p>
          <p>Endless Messages</p>
          <p>Infinite App Usage</p>
          <button type="button">Join Now</button>
        </div>
      </div>
    </div>
    </div>
    </section>

Answer №2

The placement of your first .card-body element is incorrect as it is located outside the first card. It should be within the card's div, following the .card-header div like the rest of the elements. To correct this, ensure that your card structure follows this format:

<div class="card">
  <div class="card-header">
   //content for card header goes here
  </div> //end of card-header div
  <div class="card-body">
   //content for card body goes here
  </div> //end of card-body div
</div> //end of card div

To fix this issue, simply move the entire block of code for .card-body right after the closing

<h3>Chihuahua</h3></div>
.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Concealing the .html extension within hyperlinks

If I have a link on my website located at public_html/index.html like this: <a href="pictures/index.html">Link to picture</a> When clicking the "Link to picture" link which leads to a folder using index.html file, the URL displayed in the add ...

Resizing a damaged HTML table to fit within a designated width using CSS

Here is a challenge - I have some broken HTML that I can't touch, and don't want to use JavaScript to fix. My goal is to make it fit within a specific width: http://jsfiddle.net/P7A9m/2/ <div id="main"> <table> <tr> ...

Creating a safe and secure method to access social media by utilizing the user account profile of a third-party web application

Looking to enhance a web application that features user accounts and profile pages, I am seeking advice on how to seamlessly link users' Facebook, Twitter, and LinkedIn accounts to their profiles. Additionally, I want to find a secure method for stori ...

The example in the MUI x-data-grid documentation always seems to fall short of expectations

I followed the code from the material-ui library documentation located at this link: https://mui.com/x/react-data-grid/layout/#flex-layout My aim is to set up a flex layout on my project, I went through the steps mentioned in the documentation but keep ...

Getting rid of a particular jQuery animation

I have been searching all over the site, but my limited knowledge prevented me from finding the right solution. I've been working on my website and had previously used a different theme. I have made several changes and am quite happy with it overall. ...

The internal style and script specified within the <head> section are not being rendered

Within my Joomla website using the T3 template, I inserted the following "Custom Code" just before the closing </head> tag: <style type="text/stylesheet"> div.t3-sidebar.t3-sidebar-right{ background: #F8F8F8 none repeat scroll 0% 0%; ...

Thymeleaf causing Spring IO POST form to redirect to incorrect URL

One of the challenges I'm facing while coding a website is with a form for uploading files. Ideally, when accessing the URL http://localhost:8080/uploadRevision/{docId}, it should lead to http://localhost:8080/uploadRevisionLanding and then redirect b ...

Styling with CSS using the em unit to make an image half the size of its parent div element

I'm struggling with resizing an image within a div using the em size unit. I want the image to be half the size of its parent div, so I set both the width and height CSS properties of the image to 0.5em. However, when looking at the code below, you c ...

"Challenges Encountered When Implementing CSS Card Flip

Can anyone help me with a strange problem I'm experiencing with my css card flip code? The card seems to only flip when I move my mouse away from it. Any insights on what might be causing this behavior? Thank you in advance for any assistance. ...

Giving identification to a pair of elements located within the same column

Struggling with assigning IDs to two elements in a single column - a dropdown and a text element. Managed it in the first scenario, but encountering issues in the second one. Seeking assistance on this matter. Scenario 1: <td> <sele ...

Deleting a property once the page has finished loading

My issue is a bit tricky to describe, but essentially I have noticed a CSS attribute being added to my div tag that seems to come from a node module. The problem is, I can't seem to find where this attribute is coming from in my files. This attribute ...

The file upload button in the problem submission form is malfunctioning, causing the expected pop-up window to not appear

Having an issue with my form validation using the Parsley JS plugin. On pages where the Parsley plugin is active, the form input type="file" is unresponsive. The button animates when clicked but there is no pop up to select a file for upload. Additionally, ...

Is it possible to update table cell content depending on selected option?

Displayed here is the select block: <form> <select id="select"> <option disabled selected value="choose"> CHOOSE </option> <option value="i2g" id="i ...

Delayed synchronization between CSS animation timing and JavaScript carousel interval causes a slight lag

I am currently working on a slider where one dot grows and another one follows suit. However, I have encountered a strange issue. I set the interval option to 2000ms for the slider and the CSS timing to 2000ms. div.bubble { height: 100px; border-ra ...

Having trouble retrieving my .scss bundle file from a different directory

I am trying to access my .scss file that imports all the other .scss files (they are all imported in styles.scss). Even though I have added the path to my angular cli file, the file is still not accessible and no styling is being applied to my html elemen ...

What is the best way to conceal the outline in a popup window?

I have successfully implemented a popup/modal window using JavaScript, but now I need to find a way to hide the outline map container. The initialization code for the map is as follows: self.mapDialogOptions = { autoOpen: false, m ...

What steps can be taken to identify the referrer of external links when the target attribute is set to "_blank"?

Can't seem to capture the Referrer with PHP: $_SERVER['HTTP_REFERER']; Whenever visitors land on mywebsite.com from external-web-site.com via a link with target="_blank", for example: ... <a href="http://mywebsite.com" target ...

Transforming the DOM using jQuery

I am looking to manipulate the DOM using jQuery. This is the initial source code: <td class="name"><a href="position_details.php?x=-109&amp;y=95">21</a> </td> <td class="name"><a href="position_details.php?x=-109& ...

I keep encountering a syntax error in my AngularJS project - what could be causing this

I'm encountering the following error in my AngularJS project. Can you assist me with resolving it? Error angular.min.js:117Error: [$parse:syntax] http://errors.angularjs.org/1.5.6/$parse/syntax?p0=Shoping&p1=is%20an%20unexpected%20token&p2=8 ...

Is Consistency Possible with CSS Transition Direction?

Take a look at this example: https://codepen.io/jon424/pen/XWzGNLe In the provided code snippet, there is a button that can toggle the visibility of an image. When clicked, the image disappears from bottom to top and reappears when clicked again. The use ...