How to delete the content of the ::after pseudo-element from the final span element

Struggling to clear the content of the ::after pseudo-element from the final <span> item. I've successfully removed it from the others, but this one seems to be giving me trouble.

http://jsfiddle.net/L6d6w1ys/

HTML:

<section class="comments">
                <h3>Comments:</h3>
                    <div class="radius panel">
                        <div class="comment-meta">
                            <div class="row">
                                <div class="large-3 columns">
                                    <img src="http://placehold.it/250x150">
                                </div>
                                <div class="large-9 columns">
                                    <span>User 1</span>  <span>Date: 19/10/2014</span>
                                    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Iusto ullam veritatis cupiditate soluta qui, numquam laudantium fugit! Cum reiciendis sapiente doloremque molestiae laudantium quas aut, itaque rerum minus natus sed.</p>
                                </div>
                            </div>
                        </div>
                    </div>
                </section>

CSS:

 .comments {
            p , span{
                font-size: 14px;
            }
            .comment-meta span{
                &:after{
                    content: " | ";
                    margin:0 15px;
                }
                &:last-child:after{
                    content: " ";
                    margin: 0;
                }
            }
        }

Answer №1

The reason it is not functioning correctly is due to the fact that the span:last-child selector is unable to target any <span> elements.

Given the structure, there is no <span> element that is the last child of its parent.

Instead, consider using :last-of-type as an alternative:

.comments {
  p , span{
        font-size: 14px;
    }
    .comment-meta span {
        &:after {
            content: " | ";
            margin:0 15px;
        }
        &:last-of-type:after {
            content: none;
            margin: 0;
        }
    }
}

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

Is it possible to modify the content of an element with a click event in Angular/HTML?

How can I implement a feature in my mat-accordion using mat-expansion-panels where the text becomes underlined when the panels are clicked? I want the title to be underlined when the panels are open and for the underline to disappear when they are closed ...

Concealing JW Player Video Link within Source Code

<div id="movie">...</div> <script> player("film").customize({ width:800, height:400, playlist: [{ file: "https://movielink.mp4", image: "https://moviepic.jpg", tracks: [{ file: "http://movi ...

The custom directive in Vue utilizes the refreshed DOM element (also known as $el)

I am looking to create a custom directive that will replace all occurrences of 'cx' with <strong>cx</strong> in the Dom Tree. Here is my current approach: Vue.config.productionTip = false function removeKeywords(el, keyword){ i ...

Is there a unique shape element, such as a true circle, available in HTML5?

There doesn't seem to be any documentation on this, suggesting they may not exist. However, it's always worth investigating. I am in search of a perfectly circular (or any polygon shape other than a rectangle) element. I can create a circle in c ...

Tips for properly passing data from Ajax to PHP and extracting value from it

I'm curious about how to receive a value from Ajax and then send that value to PHP. Can anyone provide some guidance on this? Specifically, I need the percent value obtained from Ajax to be sent to $percent for option value. <div class="form-g ...

Issues with the dropdown menu functionality occurring on a .Net6 MVC app razor page

I recently created a dropdown menu using bootstrap. It functions perfectly when I load an HTML file in VScode. However, I encountered an issue when I tried using the same dropdown markup in a .NET6 MVC app's .cshtml file. When I click on the dropdown ...

Verification symbols in Unicode

I'm on the hunt for a universal checkmark symbol that is compatible across various operating systems and web browsers. I've tested out the following two options: Version 1: ✓ Version 2: ✔ (source) However, these symbols seem to be working ...

Using srcset and picture together to optimize images for various screen sizes

At my workplace, we are in the process of devising a strategy to integrate responsive images into our custom framework. Our goal is to have one centralized solution that caters to all image use cases. After investigating, it appears that using srcset for ...

What is the reason behind the incompatibility of css background-size/position with the shorthand background url?

I had been working on a concept for a slideshow or single-page website and reached a good stopping point. Since I had outlined my idea on a JSFIDDLE, I decided to tidy up my CSS. Each of the 5 tabs used similar lines of CSS except for the background image. ...

What's Going on with My Angular Dropdown Menu?

Snippet of HTML code: <li class="nav-item dropdown pe-3"> <a class="nav-link nav-profile d-flex align-items-center pe-0" (click)="toggleProfileMenu()"> <img src="assets/img/profile-img.jpg" alt=& ...

Is there a workaround using jQuery to enable CSS3 functionality across all browsers?

Is there a way in jQuery to make all browsers act as if they have CSS3 capabilities? ...

The CSS property input::-webkit-outer-spin-button adjusts the margin-left and is exclusively visible in Chrome browser

Strange things are happening... Let me share the code for my inputs: #sign_in input#submit { height: 56px; background-color: #88b805; font-weight: bold; text-decoration: none; padding: 5px 40px 5px 40px; /* top, right, bottom, left ...

When the page is scrolled, the div is fixed in place and a class is dynamically added. Some issues may

Greetings everyone, I have a webpage with two floating divs - one is about 360px wide and the other has an auto width. As the page scrolls, the left div is assigned a class that fixes it to the screen, allowing the other div to scroll. This functionality w ...

Problem uploading images to server and database

I'm currently experiencing difficulties with photo uploads on my website. The issue arises at the $fileName = basename($_FILES["file"]["name"]); line where I receive the error message "Please select a file to upload". There seems to be no database in ...

Exploring the characteristics of images in Javascript

I've gone through my code multiple times but I just can't figure out why it's not functioning correctly... Could someone shed some light on this? What am I missing here? The purpose of the code is to allow users to input different values i ...

In an AJAX response, the button will be disabled if any checkboxes are left unchecked, regardless of their group

This text has been inspired by a thread on Stack Overflow regarding disabling a button based on checkbox selection In the original post, the button is disabled unless at least one checkbox is checked. In my scenario, I have two sets of checkboxes: <d ...

Apple's iPhone does not adhere to media query specifications

My responsive website was functioning perfectly on desktop, Android, and Windows Phone devices. However, when I asked my friends to check it on their iPhones running iOS 10, they informed me that the media queries were being ignored on iPhone models 5, 5s, ...

Ensure the HTML table's <td> cell width automatically adjusts to accommodate the image, regardless of its dimensions

Has anyone encountered a strange issue while building an HTML table for an HTML email? Whenever I insert an image into a <td>, it causes the cell to expand to its maximum width, affecting all the columns to the right by resizing them to their minimum ...

Developing HTML5 animation by utilizing sprite sheets

Struggling to create an engaging canvas animation with the image provided in the link below. Please take a look at https://i.stack.imgur.com/Pv2sI.jpg I'm attempting to run this sprite sheet image for a normal animation, but unfortunately, I seem to ...

Panel of numerous buttons (bootstrap)

Currently, I am working on incorporating a panel of buttons using Bootstrap. My goal is to have these buttons arranged in a grid format on desktop view and collapse into a single column on mobile devices. I envision that when button (X) is clicked, the co ...