Is it possible to apply CSS to only the first element?

I have designed a pricing form like the one shown below:

To view a full page version of my code for easier reading, please click on the link provided.

@import url('http://fonts.googleapis.com/css?family=Indie+Flower');
@import url('http://fonts.googleapis.com/css?family=Open+Sans:300,400,700');

body{
    background-color: rgb(237, 237, 237);
}

#pricing{
    width: 1340px;
/*     margin: 100px auto; */
    font-family: 'Open Sans', Helvetica;
}

.price_card{
    width: 295px;
    max-height: 173px;
    background: rgb(255, 255, 255);
    display: inline-table;
    top: 0;
    border: 1px solid green;
}
.price_card:not(:last-child){
    margin-right: 32px;
}
.header{
    color: rgb(255, 255, 255);
    background-color: rgb(113, 191, 68);
    font-size: 20px;
    font-weight: 100;
    height: 68px;
    display: block;
    text-align: center;
    padding: 28px 0 0px;
}
.price{
    width: 100%;
    font-size: 18px;
    font-weight: 300;
    display: block;
    text-align: center;
    padding: 10px 0 10px;
}
.name{
    width: 100%;
    font-size: 25px;
    font-weight: 100;
    display: block;
    text-align: center;
    padding: 0;
}
.features{
    list-style: none;
    text-align: center;
    color: rgb(255, 255, 255);
    background-color: rgb(144, 205, 109);
    margin: 0;
    padding: 0;
}
.features li{
    margin: 0 35px;
    padding: 20px 15px;
    width: 200px;
}
.features li:not(:last-child){
    border: 1px solid rgb(242, 242, 242);
    border-top: 0;
    border-left: 0;
    border-right: 0;
}
button{
    color: rgb(255, 255, 255);
    border: 0;
    border-radius: 0px;
    height: 42px;
    width: 177px;
    display: block;
    font-weight: 200;
    background-color: rgb(113, 191, 68);
    font-size: 18px;
    text-transform: uppercase;
    margin: 20px auto 35px;
}
<div id="pricing">
  <div class="content">
    <h1>PRICE POPULAR CLOUD SERVICES</h1>
    <p>
      Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ratione voluptates magnam nam eligendi, maiores quis, <br />ut perspiciatis odit eos accusamus modi sequi laborum veritatis quasi harum dolorem maxime, magni at!
    </p>
    <br />
  </div>
  <div class="price_card">
    <div class="header">
      <span class="name">Google Cloud</span>
    </div>
    <ul class="features">
      <span class="price">800 USD</span>
    </ul>
    <button>More info</button>
  </div>
  <div class="price_card">
    <div class="header">
      <span class="name">Amazon Cloud</span>
    </div>
    <ul class="features">
      <li class="price">1000 USD</li>
    </ul>
    <button>More info</button>
  </div>
  <div class="price_card">
    <div class="header">
      <span class="name">GO DADDY</span>
    </div>
    <ul class="features">
      <li class="price">1200 USD</li>
    </ul>
    <button>More info</button>
  </div>
  <div class="price_card">
    <div class="header">
      <span class="name">PLUS+ </span>
    </div>
    <ul class="features">
      <li class="price">2000 USD</li>
    </ul>
    <button>More info</button>
  </div>
</div>

I am facing two issues and need your help to resolve them:

As you can observe:

  1. The first element with class price_card has applied CSS styles while the others do not.

Why am I encountering this problem?

  1. Being inexperienced in creating responsive websites, could you provide an example at a resolution of approximately 800x400 pixels where only two cards scale in each row?

Answer №1

You have utilized a different HTML element within one of your sections.

Modify:

<div class="price_card">
<div class="header">
  <span class="name">Google Cloud</span>
</div>
<ul class="features">
  <span class="price">800 USD</span>
</ul>
<button>More info</button>

To:

<div class="price_card">
<div class="header">
  <span class="name">Google Cloud</span>
</div>
<ul class="features">
  <li class="price">800 USD</li>
</ul>
<button>More info</button>

Your list should start with an "li" element instead of a "span".

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

In Chrome, there is a single pixel missing below the <dl> element

While my website's basic list looks great on Firefox and IE, there seems to be one missing pixel line in Chrome. Check out this JsFiddle link shared by Jared in the comments for reference. If you're not seeing the missing line, try adjusting th ...

What is the best way to choose all <pre> tags that have just one line of content?

$('pre:contains("\n")') will target all <pre> elements that have one or more newlines. Is there a way to specifically select <pre> tags with no newline or only one at the end? Any shortcuts available? match <pre>A< ...

What is the best way to include a class in the <td> element of a dynamic table?

My goal is to sum up the values in a specific column of a dynamic table by attaching an id property to each row. I am specifically focused on assigning an id to each <td> in every row of the table. UPDATE: Although I have all 4 keys in the <td> ...

What is the best way to position two divs side by side at the bottom of the

When trying to align my second div with the first one, I face an issue. If the text above the first blue box is longer, the second div appears to be outside the line of the box. Changing the relative position doesn't solve this problem either. When th ...

What is causing my div to transition repeatedly from the bottom to the top instead of the center position?

Currently, I am using React and Tailwind CSS and facing an issue with the transition property. My goal is to have a div grow in width and height from the center until it covers the entire viewport when a specific state variable becomes true. The content in ...

Viewing a document generated using the Google Drive API using the Google Drive Viewer

Using the Google Drive API, I am able to generate a document and receive some URLs: alternateLink : https://docs.google.com/document/d/xxxsome_idxxxxx/edit?usp=drivesdk embedLink https://docs.goo ...

Add a plethora of images to the canvas

Just starting out with Fabric.js and trying to figure out how to draw a picture on the canvas after a drop event. I managed to do it once, but am struggling with inserting more pictures onto the canvas (each new drop event replaces the previous picture). ...

Steps for including a path to a base64 encoded image

I am currently facing a challenge in embedding images into my emails where I need to encode them using an online tool. The issue I am encountering is that the email template I am using has a dynamic URL, with ${loginurl}/images as the path to my image. H ...

What is the best way to create a variable within this loop that remains constant and does not update?

I'm having some trouble phrasing this question, but I'm working on creating a loop to display dates for a calendar. So far, everything seems to be working well, except for one thing. My goal is to allow users to click on a date within the calenda ...

Is it possible to make a div resize to fit its container?

I have a square block measuring 100*100px. The container block it is within can be resized. I need the inner block to adjust its size dynamically so that it always fits inside the parent container without overflow and maintains its square shape. Important ...

Tips for positioning elements within an ng-repeat list using absolute positioning?

Here is the HTML code: <div class = "container"> <form ng-submit = "createSticky()"> <input ng-model="formData.data" type="textarea" name="sticky_content" placeholder="add sticky text" required="true"/> <input ng-model= ...

Having trouble getting the background image to display within the div element

I'm having trouble getting my background image to display in the specific div I want it in. It works fine when I place it in other elements, like the body element, but for some reason, it's not showing up where I need it to. Any chance you could ...

Issue with Audio TAG functionality in Internet Explorer 9

I am facing an issue with my jQuery code that generates an audio tag. The code works perfectly in Firefox and Chrome, but it is not functioning properly in IE9. Here is the code snippet: $(document).ready(function () { var source = "/TTS.aspx?tts=" + ...

Exploring json data with angularjs

I am facing a challenge with handling a complex JSON object by looping through it and displaying the data in a form. To tackle this, I have created a small service similar to the one shown below: service.myApprovalResults = function(){ var url = " ...

What is the process for arranging multiple text boxes beside a radio button upon selection?

Displayed below is the HTML code for a page featuring three radio buttons- <html> <body> <form> <input type="radio" name="tt1" value="Insert" /> Insert<br /> <input type="radio" name="tt2" value="Update" /> Update<b ...

What could possibly be causing this element to shift side to side (in IE only) during the CSS animation?

UPDATE: Issue occurring on Internet Explorer 10, Windows 7 When using the transform property to adjust the horizontal position of an element during animation, the vertical value is updated as well. However, despite setting the horizontal value to the same ...

Guide for utilizing a table value as a parameter in a mySQL query with PHP

My website features an HTML table that is filled with data pulled from a mySQL table using PHP. Each row in the table is clickable, and when clicked, it opens a modal that contains a form to update and submit data back to the database using a mysql update ...

Position of fixed div set relative to its parent fixed div

I'm facing an unusual situation where I need a fixed div to be positioned relative to its parent, which is also a fixed div. When you take a look at my example, everything will become clear. <div class="drawer"> <p>Drawer</p> & ...

Using Jquery to Select Start and End Dates

I currently have two date input fields labeled as Start Date and End Date for a specific Project. If the user chooses a start date that is earlier than today's date but does not choose an EndDate, I want to indicate that the project is ongoing. How c ...

What is the best way to target and manipulate the transform property of multiple div elements in JavaScript?

Looking at this code snippet, my goal is to have all the boxes rotate 180deg with a single click, without needing to apply different ID names: function rotateAllBoxes() { var boxes = document.getElementsByClassName("box"); for (var i = 0; i < box ...