Eliminate :hover effects from the :after elements' content

I am trying to eliminate the hover effect from the content inserted using the css selector :after. Below is my code where I want to remove the underline hover effect from >

HTML

<ul class="path_string_ul">
    <li>Home</li>
    <li>MENU</li>
    <li>SUB-MENU</li>
    <li>SUB-SUB-MENU></li>
</ul>

CSS

.path_string_ul li{
            display:inline-block;
            list-style:none;
            cursor:pointer;
        }
        .path_string_ul li:hover{
            cursor:pointer;
            text-decoration:underline;
        }
        .path_string_ul li:after{
            content:'>';
            margin:0 10px;
            pointer-events: none;
            text-decoration:none !important; /*Doesn't work*/
        }
        .path_string_ul li:hover:after{
            text-decoration:none !important; /*Doesn't work*/
        }
        .path_string_ul li:last-child:after{
            content:none;
        }

Check out this FIDDLE link for more details.

Answer №1

The reason for this is that the default display property of the pseudo-element created by the :after selector is inline. This causes the text-decoration property not to be applied to the element. To resolve this, you can change the display property to inline-block:

.path_string_ul li:after {
     content:'>';
     margin:0 10px;
     pointer-events: none;
  +  display: inline-block;
     text-decoration:none !important;
}

Answer №2

To prevent text-decoration:underline from being affected, you can apply float:right to the :after element.

.path_string_ul li:after {
   content:'>';
   float:right;
   height:100%;
   margin-left:10px;
   pointer-events: none;                
}       

Check out the demo here.

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

Web server decides on "Multiple Options" while utilizing %3F instead of "?" in the URL

I have been using the Lazarus-IDE for a project and encountered an issue with one of its components that doesn't accept "?" in the URL for online help info. I attempted to encode "?" as "%3F" in the URL, thinking it was the correct encoding, but both ...

I am having issues with my JavaScript code, I could really use some assistance

Currently, I am developing a custom file search program. The goal is to have a textarea where users can input text, which will then generate a clickable link below it. However, I am facing issues with the current implementation. Below is the snippet of my ...

Customizable Designs in Oracle Application Express version 4.2

In my work supporting the organization, I am using APEX 4.2 to create a Training Calendar. While I am not a DBA or programming expert, I have been learning through trial and error. The calendar is already set up, but I am looking for a way to customize ho ...

Create a responsive layout with divs using Bootstrap

As an aspiring Bootstrap and Ruby on Rails developer, I am in need of an adaptable "div" element. Here is my current code snippet: <div class="container-fluid"> <div class="row-fluid"> [if true] <div class="span2"> div1 ...

Customize the images displayed for individual checkboxes in a QTreeView

I have customized a QTreeView by subclassing it, and I now have two columns with checkboxes. My goal is to assign different images to each column - one for the first column and another for the second column. While I am aware that I can change the image usi ...

The table is unable to properly display the array data

My code includes an AJAX function that sends a GET request to an API and receives data in the format shown below: { "firstname": "John", "lastname": "Doe", "email": "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="6 ...

Modifications to contenteditable elements result in a change to their IDs

Having some trouble with the behavior of a contenteditable div. The code structure is like this: <div contenteditable="true"> <p id="element-id-1">element-id-1</p> <p id="element-id-2">element-id-2</p> </div> E ...

Tips for creating a customized dropdown menu that opens upwards without relying on Bootstrap

Looking for some assistance with creating an animated dropdown menu that slides upwards. Any help is appreciated! $('.need-help').click(function() { $('.need_help_dropdown').slideToggle(); }); .need-help { background:url(../im ...

What is the best way to display database information on my webpage according to the selected item in the combo box?

Whenever I visit my sample.php page, the only thing that appears is my combo box. However, when I start selecting a value from the combo box, that's when the data from my database, which is fetched from getyear.php, is displayed. What I want to achie ...

Utilize the HTML canvas to sketch on an image that has been inserted

I have a HTML canvas element within my Ionic application. <canvas id="canvas" color="{{ color }}" width="800" height="600" style="position:relative;"></canvas> Within this canvas, I am loading an image. Below is the code snippet from the con ...

What causes my CSS styles to vanish upon refreshing the page in Next.js?

After setting up a CSS folder within my app directory and importing the files into components for use, I noticed that the styles are applied initially. However, upon refreshing the page, they all disappear. I attempted to resolve this issue by going back ...

Retrieving raw PCM data from webAudio / mozAudio APIs

I have been exploring ways to store the output from the webAudio API for future reference. It seems that capturing PCM data and saving it as a file might meet my needs. I am curious to know if the webAudio or mozAudio APIs have built-in functionality for ...

Creating HTML tables dynamically using PHP

I am currently working on creating a dynamic HTML table by querying the database using PHP. I am facing some challenges in understanding how to combine two different loops to ensure the correct generation of the desired table. <table><tr> & ...

Interactive preview of PDFs with pdf.js adaptation

How can I update my PDF preview when resizing the window? Currently, the canvas resizes but the PDF preview remains the same size. I am struggling to find a solution for this. var myState = { pdf: null, currentPage: 1, zoom ...

How to Use jQuery Slice to Display the Top N Items from a Dropdown Menu

How can I display only the top 10 results from multiple UL lists in my navigation? The code snippet provided below currently works for the first list, but how can I extend this functionality to all of the lists? $(document).ready(function() { var elem ...

Using the table component object in Angular, you can easily set focus to an input field contained within a <td> element of a table

Currently, I am working on a table that dynamically populates data. Within this table, there are multiple input tags and I am looking to enhance user experience by enabling the focus to shift to the next input in the following td tag when the right arrow k ...

Creating a sleek drop-down menu using HTML and CSS

I am currently working on creating a drop-right menu using CSS, but I seem to be stuck... After searching for examples on the internet, I found that most of the code snippets are quite lengthy and overwhelming. I attempted to implement one of them, but t ...

PHPBB authentication system

After experimenting with the script based on the guidance I received from you all, I've encountered another issue. When I click 'login' on the login form, it displays this message: The page isn't redirecting properly. Firefox has detect ...

Is it possible to manipulate CSS on a webpage using javascript?

I have incorporated this piece of JavaScript to integrate a chat box onto my website: window.HFCHAT_CONFIG = { EMBED_TOKEN: "XXXXX", ACCESS_TOKEN: "XXXXX", HOST_URL: "https://happyfoxchat.com", ASSETS_URL: "https://XXXXX.cloudfront.ne ...

Looking for a way to align two child divs next to each other within a parent div? I've tried multiple methods, but none seem to be effective

Despite trying various methods like using inline-block and float, the divs in my code continue to stack on top of each other. What could be causing this issue? #resources { position: fixed; top: 0; left: 0; z-index: 1; display: block; wid ...