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

"The JQuery .validate method is not compatible with this property or method" - error message displayed

I seem to be facing a problem that I can't seem to solve. I keep getting an error message that says "Object doesn't support this property or method" while using jquery-1.10.4. The .validate method is not functioning properly for me. Any assistanc ...

Ways to stop the floating label from blending with the input field

Attempting to incorporate the Bootstrap Material design theme into my project, I have implemented a basic text input field using the code below: <div class="form-control-wrapper"> <input class="form-control empty" type="text"></input> ...

Transforming data from a particular csv file and embedding it into an html document

I am currently working on a feature that allows users to select a specific CSV file and display it as an HTML table on the webpage with the click of a button. The process involves: Selecting the desired file from a dropdown menu to determine the CSV fi ...

Chrome and Firefox: Images cling together

I've encountered an issue with my recently launched website. Some images in a grid appear to be stuck together, but this problem only occurs in Firefox and Chrome browsers. Oddly enough, zooming in to around 110% then back to 100% seems to temporarily ...

I am looking to implement user authentication using firebase, however, the sign-in page is currently allowing invalid inputs

<script> function save_user() { const uid = document.getElementById('user_id'); const userpwd = document.getElementById('user_pwd'); const btnregister=document.getElementById('btn-acti ...

The initial item in the Materializecss slider is failing to display

Currently, I am attempting to implement materialize slider with skrollr. The setup is functional; however, only the first item of the slider is set to opacity: 0 initially. https://i.stack.imgur.com/urSww.jpg After a brief delay, the second item becomes ...

A data table created with Bootstrap is not displayed inline with the pagination feature

Customizing Bootstrap Data Table Code Instructions on how to customize this code: <div class="row"> <div class="col-sm-5"> <div class="dataTables_info" id="example_info" role="status" aria-live="polite"> Showing 1 to 10 of 2 ...

What is the method for executing a server-side script without it being transmitted to the browser in any way?

Although the title may be misleading, my goal is to have my website execute a php file on the server side using arguments extracted from the html code. For example: document.getElementById("example").value; I want to run this operation on the se ...

Utilize CSS Grid to adjust the size of an image

Hi there! I'm currently working on resizing an image using a CSS grid layout. Here's the CSS code I have so far: /* Reset */ * { padding: 0; margin: 0; } html { height: 100%; background-image: url("/assets/images/background.p ...

Tips for populating an array with boolean values when a checkbox change event occurs:

I am looking to fill the answers array with boolean values. The checkboxes on my form are generated dynamically, but there will only be four of them. When a checkbox is unchecked, its corresponding value in the answers array should be false; when checked, ...

What is the method for increasing the left margin of the back button on the default header in React Native?

My attempt to increase the space on the back button from the left side of the header in my React Native code has been unsuccessful. headerStyle: { paddingLeft: 60 } https://i.stack.imgur.com/0RFb0.png I also experimented with adding margin ...

decorating elements in a line with colored backgrounds

I am facing an issue where I want to keep three divs aligned horizontally on the same line, but their background colors are causing them to not align properly. Adding margin or padding causes the divs to wrap up instead of staying in line. #service_cont ...

Experiencing difficulty in retrieving the title of the latest post

In my current Wordpress project, I'm facing an issue where a link is supposed to play a wav file based on the title of the post. For example, if the post title is 'one', then it should play one.wav from the uploads folder. However, the sound ...

What steps are involved in integrating QuickBlox on your website?

I am completely new to web development and have a question about integrating QuickBlox into my website using JavaScript. I have included the necessary JavaScript files in my website and set up the QuickBlox admin application, but I'm not sure how to p ...

Searching for the class _XWk using BeautifulSoup: A beginner's guide

I have discovered a way to locate Google's "quick answer box" by searching for the "_XWk HTML Element using the code below: from bs4 import BeautifulSoup # Beautiful Soup is part of the bs4 package import requests URL = 'https://www.google.com/ ...

Icons on the top banner that adjust to different screen sizes

I am still getting acquainted with Wordpress, so please bear with me if I use incorrect terminology or ask silly questions. I am eager to learn and improve. My website is focused on jewelry (using Kallyas premium), and I have a row of banner icons between ...

Reduce the size of the header in the Sydney theme for WordPress as you scroll

Currently, I am attempting to reduce the size of the header once scrolling down. My focus is on refining the child theme. Displayed below is a screenshot illustrating the appearance of the header at the top of the page: https://i.stack.imgur.com/wojGf.pn ...

Containers do not line up properly with each other. Adjusting the width leads to unexpected consequences

As someone who is new to HTML and CSS, I am facing a challenge with aligning the items within a navigation bar on my website. The list serves as a navigation bar and is contained inside the "inner header" div. While I was able to align the entire "nav" con ...

Chrome and Firefox browsers are not supporting HTML simple anchor links

Creating a portfolio page at this link (http://198.96.94.51/v2/) and encountering an issue with the navigationMenu. When rapidly clicking on the links on the side, they do not redirect to the correct anchor point (some don't move the page at all). I h ...

Rearrange and place items at the dropped location

I am looking to create a drag-and-drop feature for moving items from a list of products to an empty container. Upon completion, I need to save the location and the selected items in a database so that I can recall this layout later. However, I have encoun ...