I need to know how to focus on the second span within a list

How can I properly align the food prices in the menu section on my website? I attempted to place each price within a span element inside an li element, but it only worked for the first item. Do I need to adjust my use of nth-child?

I've tried using nth-child, but it doesn't seem to be working as expected. Could there be an error in how I'm implementing it?

You can view the code here: https://jsfiddle.net/Gsimelus92/z8dna4c2/3/

.apett-left ul li:nth-child(1) {
          margin-bottom:5px;
          font-size: 19px;
          font-weight: bold;
         }

     .apett-left span:nth-child(1){
          color: #AA8A45;
          margin-left:130px;
         }

     .apett-left ul li:nth-child(2) {
          margin-bottom:5px;
          font-size: 14px;
          font-weight: normal;
          border-bottom-style: dotted;
          border-color: white;
          padding-bottom: 5px;
          margin-bottom: 15px;
         }

     .apett-left span:nth-child(2){
          color: #AA8A45;
          margin-left:130px;
            }


         /********************foodder and price 2 ******/


     .apett-left ul li:nth-child(3) {
          margin-bottom:5px;
          font-size: 19px;
          font-weight: bold;
         }

     .apett-left ul li:nth-child(4) {
          margin-bottom:5px;
          font-size: 14px;
          font-weight: normal;
          border-bottom-style: dotted;
          border-color: white;
          padding-bottom: 5px;
          margin-bottom: 15px;
        }

     .apett-left span:nth-child(2){
          color: #AA8A45;
          margin-left:200px;    
         }
   <section class="pat-a">
      <div class="apett-pic">
        <img src="bbq-nachos.jpg"width="800" height="500">
      </div>
      <div class="apett-food">
          <div class="apett-left">
             <ul>
               <li>Mozzarella Sticks <span>$7.00</span></li>
               <li>Add pulled pork /homemade chilli / bbq beans <span>$1.50</span></li>
                      
               <li>Boneless Wing <span>$0.00</span></li>
               <li>Plain / spicy / sticky bbq <span>$0.00</span></li>

               <li>biscuits & bbq beans</li>
               <li>each bicuite</li>
             </ul>                        
          </div>
      </div>
</section>

Answer №1

When attempting to target the second child span, it's important to note that there is no actual second child - only the first one exists in both cases. Each span serves as the initial child within their corresponding li. To properly address this, consider aiming for the first and second li elements and then pinpointing the span inside them using the following approach:

.apett-left ul li:nth-child(1) span {
    /* css styles */
 }
.apett-left ul li:nth-child(2) span {
    /* css styles */
 }

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

Triggering a JQuery event to switch between tabs

Currently, I am in the process of developing a web application that incorporates nav-tabs from Bootstrap. These nav-tabs consist of 4 different tab-contents. My main concern lies in determining which nav-tab the user has selected among the 4 tabs and updat ...

Experience the feeling of releasing momentum by click and dragging the scroll

One feature I am looking for is the ability to control the scroll speed when dragging, and have the scroll continue moving slightly after release instead of stopping instantly. CodePen: https://codepen.io/rKaiser/pen/qGomdR I can adjust the speed adequat ...

Creating dynamic pages using user input in Node and Express

Currently, I am facing a challenge in rendering text using node/express. Within my project setup, there is an HTML file containing a form. The file named search.ejs looks like this: $(document).ready(function(){ var userInput; $("#submit-button-i ...

Tips for Eliminating Unnecessary Space Above the Navigation Bar

I have a problem with the top navbar on my test site. There is some extra space above it that I want to remove so that the navigation extends all the way up to cover the viewport. Here is an image of what I'm trying to achieve: https://i.stack.imgur.c ...

"The sliding function of the React Bootstrap carousel is malfunctioning as it goes blank just before transitioning

Here is the code snippet I am working with: Whenever the carousel transitions to the next image, the current image disappears before displaying the next one. I am using react-bootstrap version 5.1.0, but it seems like there may be an issue with the transi ...

The getText method in Selenium seems to be malfunctioning as it is unable to retrieve any text content from

Struggling to capture the text of WebElement using two different methods, but both are returning blank strings. // Method 1 d.findElement(By.id("deliveryDate")).getTex(); // Method 2 WebElement deliveryDate = d.findElement(By.id("deliveryDate")); Sys ...

Created a CSS sliding menu, but suddenly unable to activate links on it

Recently, I created a slide out menu for the mobile version of my website. The menu is hidden beneath the page and is designed to slide out to the right when the label for a checkbox is clicked. It functions smoothly and is very responsive on mobile devi ...

Tips for setting up Greasemonkey to automatically click on an unusual link on a particular website

I'm not a master coder by any means; I can handle some scripts but that's about it. Treat me like a total beginner, please! ;-) I want to automatically expand two specific links on a webpage using a GM Script. On a French dating site in the prof ...

Is there a way to evenly space out the buttons in the Nav element with more room in between each one?

I need the buttons to be evenly spaced with more room between them. And, of course, they need to be responsive in the end. I attempted to use Bootstrap's "d-flex" class to arrange the buttons, but it didn't work as expected. If you review my Boo ...

Troubleshooting mat-accordion title problem on mobile devices

Despite reading numerous blogs and conducting extensive searches on Google, I am still unable to resolve the CSS issue related to Angular material below. Your assistance in fixing this problem would be greatly appreciated. Desktop view: https://i.stack.im ...

The onChange function is not triggered when the dropdown menu consists of only one item

I am facing an issue with my dynamically populated dropdown menu. When the dropdown contains only one element, the onChange() function of my select tag does not work as expected. It functions perfectly fine when there are multiple elements present. How c ...

Non-Modal functionalities, an alert displayed prominently in a vibrant red bar at the top of the screen

Is there a way to make the text show up at the top of the webpage in a red banner when the button is clicked? I've searched on Google and YouTube but haven't found a solution. Could someone please take a look at my code to help me figure this out ...

Online platform generating printed code

Have you checked out the website here? I'm facing a problem on that site and can't figure out why. I've installed PDO, PHP, httpd, php-mysql, but still unable to resolve the issue. I've even tried reinstalling everything and following ...

Using Javascript to place a form inside a table

When attempting to add a Form inside a Table, only the input tags are being inserted without the form tag itself. $(function () { var table = document.getElementById("transport"); var row = table.insertRow(0); var cell1 = row.insertCell(0); ...

I am having trouble setting the z-index for the navigation component in Tailwind CSS and Next.js

Currently, I am immersed in a Next.js project that utilizes Tailwind.css. Within this project, there is a header component known as nav, styled as follows: <div className="sticky top-0 z-100 body bg-white flex flex-row items-center">Nav con ...

Calculate the total price using jQuery

I’m a beginner in JavaScript and I’ve hit a roadblock. I have a plus and minus button that adds up product quantities, but I need the total price to reflect this as well. Some products can only be purchased in multiples of 2, 5 or 10. Here is the HTML ...

What's the best way to make sure an image and text are perfectly aligned on the

How can I align an image and text on the same line, as currently the a tag is higher than my text? Here is the HTML code: <div class="author-name"> <img class="article-author-img" src="{{ preload(asset('assets/st ...

Troubles with Conditional Application of CSS Styles to a Twitter-Bootstrap Table

I am facing an issue with highlighting a row in a table when a barcode is entered. Despite following similar scenarios and checking my code, the CSS doesn't seem to be applied. Can anyone help me figure out what I'm missing or how I can fix this? ...

The width of the menubar dynamically adjusts upon mouse hover using CSS

I encountered a problem with my menu and submenu. When I hover over the list elements in the main menu, the width of the menu items changes abruptly which looks confusing. I tried fixing the width, but then there is too much space between the menu items. ...

Grid layout with card tiles similar to Google Plus

I'm looking to develop a scrolling grid with card tiles similar to Google Plus that has three columns. I am currently using Material UI, but I can't seem to find the right functionality for this. I have experimented with the standard Material UI ...