After hovering over the box, we can observe the :after pseudo

Encountered an issue where the box fails to appear when hovering over the :after element.

HTML CODE:

    <div class="top_line_dropdown">
        <span class="logged_in_user">
            <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="d190b5bcb8bf91b0b0b0ffb2b2">[email protected]</a> (Admin)

            <div class="top_line_dropdown_content">
                aaaa
            </div>
        </span>
    </div>

CSS

.top_line_dropdown {
  display: inline-block;
  margin-left: 22px;
}
.top_line_dropdown .logged_in_user {
  font-family: red;
  font-size: 11px;
  color: #999;
}
.top_line_dropdown .logged_in_user:after {
  content: "\f078";
  font-family: FontAwesome;
  font-weight: none;
  font-size: 9px;
  color: #999;
  padding-left: 5px;
}
.top_line_dropdown .logged_in_user .top_line_dropdown_content {
  display: none;
  position: absolute;
  background-color: #f9f9f9;
  min-width: 160px;
  box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
  padding: 12px 16px;
  z-index: 1;
  right: 50px;
}
.top_line_dropdown .logged_in_user:hover:after .top_line_dropdown_content {
  display: block;
}

Upon changing from :hover to :hover:after, the expected box does not show up. The root cause of this issue remains elusive.

You can view a demonstration here: JSFIDDLE

Answer №1

The reason why :hover:after behaves in this way is because it is a pseudo element generated by the CSS, not an actual child of the .top_line_dropdown_content element. When you use :hover, it detects when the element is being hovered over and then applies styles to its children. To clarify, let me demonstrate with an example. I will include the ::after pseudo-element within the code snippet.

<div class="top_line_dropdown">
    <span class="logged_in_user">
        <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="c283a6afabac82a3a3a3eca1a1">[email protected]</a> (Admin)

        <div class="top_line_dropdown_content">
            aaaa
        </div>
        ::after
    </span>
</div>

In the given example, the ::after element represents where your element would be inserted.

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

Having trouble unchecking a checkbox in reactjs?

Hey there, I've been using a checkbox on my website and for some reason, I can't seem to uncheck it. Any ideas why? const [checkBoxEmailPersonalized, setCheckBoxEmailPersonalized] = useState(false); const onEmailPersonalized = (event) =& ...

HTML5 - Adding Space to Main Section with a Two-column Layout

After spending 3 and a half hours racking my brain, I still can't figure out how to complete two seemingly simple tasks. First, I need to pad the outside of paragraph div, and secondly, I want to split the main section into two columns to add some lin ...

What is the best way to incorporate arrow buttons on my website in order to unveil various sections on the homepage?

A colleague and I are collaborating on a website for his cookery business. He has sketched out some design ideas on paper, one of which involves having a homepage with 4 different sections stacked on top of each other. Each section would have an arrow butt ...

Ways to ensure your page stays confidential

Concept: Exploring the idea of making specific pages on a website private. For example, having 4 navigation links where one link leads to a private page that requires a username and password for access. Currently, my practice website has 7 links directing ...

Adjusting HTML/CSS for various screen sizes and devices

I have designed a website, but when it is viewed on devices like iPad or iPhone, the layout does not adjust to fit the screen properly. The text box containing my name and social media buttons appears on the left side, while the background image is positio ...

What is the best method for eliminating buttons and text in a row using CSS?

I faced an issue when trying to create a row, so I improvised with the following setup. However, I actually need a proper row layout for both the Google button and telephone number button. Here are my CSS snippets: .google-button { color: white; borde ...

Using Paypal API in PHP to create a payment form

<?php $action=$_REQUEST['action']; if ($action=="") { ?> <center> <form name="_xclick" action="https://www.paypal.com/cgi-bin/webscr" method="post"> <input type="hidden" name="cmd" value="_xclick"> <input type=" ...

What are the benefits of incorporating various custom fonts through @font-face?

I feel like I must be overlooking something very simple. I have been using a single custom font with a normal font face: @font-face { font-family: CustomFont; src: url('CustomFont.ttf'); } Everything works perfectly when I use this font ...

Switch up the CSS variable within an embedded iframe

I'm in a predicament with a specific issue. I am currently utilizing Angular to incorporate an Iframe. Let's imagine the angular app as A and the Iframe as B. B is being loaded within A. Within B, I have utilized CSS variables to define colors. I ...

Relocate the form element from its current position inside the form, and insert it into a different div

I have a sidebar on my website with a search/filter form. I am attempting to relocate one of the elements (a sort order dropdown) from this form, outside the form using CSS/JS and display it inside a div on the right side. Is it possible to do this without ...

Exploring jQuery: Choosing all li elements starting from a specific index to the end

Is there a way to select the last item, li:eq('+(lastItemIndex)+')', and all subsequent items until the end? Check out this JSFiddle demo for an example of changing elements in li from 3 onwards. ...

Interact with webpage dropdown menus using Python

I'm currently working on a Python script that interacts with a webpage, specifically , to retrieve a (DNA sequence in fasta format) file. The file is automatically downloaded when a user clicks on a dropdown menu. Here's the dropdown menu: Dow ...

Problem with ngStyle: Error indicating that the expected '}' is missing

I encountered an error in the Chrome console when trying to interpret the code below: <div [ngStyle]="{'width': '100%'; 'height': '100%'; 'background-size': 'cover'; 'background-repeat&ap ...

Mobile Device Experiencing Constant Resizing Issues on Website

I have been working on my website for almost a year now, and I am facing an issue with its responsiveness on mobile devices. Despite using Bootstrap 4 and Ajax to load pages and modals, I can't seem to figure out what's causing the problem. Befor ...

Question about transparency - HTML, CSS, and Bootstrap

I adjusted the opacity of the bootstrap card to 0.8, but now I want the table to be opaque while the rest of the card remains translucent. How can I achieve this effect? I attempted to add the style opacity : 1 to the table, but it didn't have the des ...

Passing data from the <ion-content> element to the <ion-footer> element within a single HTML file using Ionic 2

In my Ionic 2 html page, I have a setup where ion-slide elements are generated using *ngFor. I am seeking a way to transfer the data from ngFor to the footer section within the same page. <ion-content> <ion-slides> <ion-slide *n ...

Having trouble positioning items to the right in bootstrap

<div id="unique-content-wrapper"> <nav class="navbar navbar-expand-lg navbar-light bg-light" id=""> <button class="navbar-toggler" id="menu-toggle"><span class="mater ...

Visualization of XML Datamarkup

I am facing an issue with a function that generates XML from a source. Everything works perfectly except for when certain fields are too long, causing the table to stretch and mess up the website formatting. Is there a way to automatically insert line brea ...

What are some ways to enhance mobile browsing with CSS?

I'm facing a challenge with optimizing my webpage for different mobile resolutions in my beginner HTML/CSS course. Whenever I use a website resolution simulator to test, the layout doesn't look right on certain settings. Is there a method to aut ...

Removing dropdown lists from input forms can be achieved without using jQuery by utilizing vanilla JavaScript

Looking to build a custom HTML/JavaScript terminal or shell. Interested in utilizing an input box and form to interact with JavaScript functions/commands. Unsure of how to eliminate the drop-down menu that appears after previous inputs. Pictured terminal: ...