Utilizing the not(:last-child) selector effectively within a list structure

I need help targeting all elements except the last one in a ul/li list with CSS. The structure looks like this:

<ul class="xxx">
 <li>
  <figure>
   [different divs / content]
  </figure>
 </li>
 <li>
  <figure>
   [different divs / content]
  </figure>
 </li>
<ul>

My goal is to apply a border-bottom style to all elements except the last one...

.xxx{
 figure:not(:last-child) {
  /* attributes */
 }
}

Any suggestions on what I'm doing wrong here? Thanks in advance!

Answer №1

Each figure element is the final one in its respective container.

To select the figure within each li that is not the last item in the ul, you should target the correct element (the li) with the pseudo-class.

li:not(:last-child) > figure

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

Safari displays text in a noticeably bigger font size compared to other browsers

I'm currently working on a website and have noticed that the fonts appear larger on Mac's Safari compared to other browsers. We are using the 'Open Sans' font from Google Fonts for our website. For example, here is a CSS snippet for ti ...

Organize data in a Vue.js table

Currently facing an issue with sorting my table in vue.js. Looking to organize the table so that campaigns with the highest spend are displayed at the top in descending order. Here is the code I'm working with: <template> <div class=" ...

Utilize ASP to gather information from bulletin board systems

Hey there! I am a beginner in ASP programming and I am looking to extract data from a specific bbs link: http://sports.williamhill.com/bet/en-gb/betting/y/5/tm/Football.html. My plan is to click a button that will take me to the page above and extract th ...

Even though the browser is displaying the CSS file in the sources panel of the development tools, Python Flask is not properly applying the CSS styles

I am facing an issue with my flask application where it is not applying CSS styling to my website. Despite trying various solutions found on Stack Overflow and the internet, none of them seem to work. Even after organizing my directories into separate tem ...

Implementing automatic activation of a tab upon page load using Angular

I am currently working with a set of Bootstrap nav pills in my navigation bar. The 'ng-init' code in my Angular script sets the 'dateState' to 'past' on page load. However, I have noticed that the 'Past Events' nav p ...

Tips for positioning elements on an HTML page by utilizing CSS styling

I have a primary container with the following CSS: .major { width:30%; height:100%; position:absolute; } Now, I want to insert web information at the bottom part which includes: About | Terms | Policies | Contact Us This content will be within the .web ...

Creating an image dynamically at runtime from a section of HTML code as it appears in the browser

Is there a way to use Java API or Jquery library to create an image from input HTML code? Alternatively, how can I capture a screenshot of a section of HTML code as it appears in the browser? For example: If I have the following HTML code: <h1>Logo& ...

What is the best way to retrieve data from a form on the server?

I'm currently working on a form and trying to figure out how to submit its contents to the server upon submission. I came across a similar question on another platform that suggested using a POST request, but I'm unsure of how to implement it. He ...

Is there a method to add HTML code statically rather than in a dynamic environment?

I'm currently in the process of developing a front-end website with no backend code, as I plan to host it on GitHub pages. I feel that adding any additional backend functionality would be unnecessary. Is there a simple method to incorporate common el ...

Tips for incorporating seamless animation effects to an element with jQuery

As I work on coding the navbar for my HTML website, I'm incorporating Bootstrap for styling and using a jQuery function to change the color of the navbar dynamically. However, I want to ensure that the color transitions smoothly when it changes. How c ...

Animate owlCarousel slide motion in reverse when using the Prev and Next buttons

The default functionality of owlCarousel is to move to the right when clicking Next and to the left when clicking Prev. However, after applying animations, both directions always move in the same direction. Check out this sample on jsfiddle to see the iss ...

Error: Unable to locate or read the file "style.scss" for import

I'm currently in the process of setting up a new vuejs project from scratch, but I've encountered an error when trying to import "style.scss" into my component. Specifically, the issue arises in the Login.vue file where I include the style.scss. ...

Would you like to justify to the right?

I am attempting to align the final element in a list to the right side: <ul> <li>one</li> <li>two</li> <li>three</li> <li id="right">right?</li> </ul> li { display: inline-bl ...

Unselect a radio button

I am currently utilizing the bootstrap radio buttons and I want to implement a feature that allows for deselecting a radio group. I came across an approach in this (Fiddle), which involves using an additional button. Instead of adding a separate button, my ...

When using the background-blend-mode property, transition-duration is not taken into account

Try hovering over the top left h1 element in this code example You'll notice that it smoothly changes the h1 element to a shade of blue in just 2 seconds. However, the transition doesn't affect the blend mode of the backgrounds. Even though the ...

Is there a way to automatically retrieve CSV data using ashx on a web page?

After researching the provided links from SO without success, I decided to reach out here for help. (For privacy reasons, the actual URL and header data have been obscured) I am struggling to automate downloading data from an HTTPS web page using Delphi ...

Switching Text in ReactJS from V to X: A Tutorial

I have been utilizing a Switch component from react-switch in my project. import Switch from 'react-switch'; render() { return <Switch onChange={this.onChangeStatus} onClick={this.onChangeStatus} c ...

"Discovering the secrets of incorporating a spinner into Angular2 and mastering the art of concealing spinners in Angular

When experiencing delay in image loading time, I need to display a spinner until the image loads completely. What is the best way to achieve this on the Angular 2 platform? <div id='panId' class="container-fluid" > This section ...

What is the best way to locate an element by its class using Selenium and Python?

<input class="inputDefault-_djjkz input-cIJ7To" name="password" type="password" placeholder="" aria-label="Password" autocomplete="off" maxlength="999" spellcheck="false" va ...

Mastering the art of finding the perfect position

I'm trying to keep the menu on top, but when I hover over one menu, the others should not overlap. How can I achieve this? Thanks for any help! Before: https://i.sstatic.net/esBw6.png After: https://i.sstatic.net/slW1n.png Expected: https://i.s ...