What is the trick to getting a pseudo class to load before an element?

Currently, I am working on designing some UI elements. Specifically, in the dropdown menu section, I have the following HTML code:

<div class="dropdown">


    <div class="dropdown-toggle mytextformcontrol" data-toggle="dropdown">
        <a href="#" class="indigo pull-left">Dropdown</a>
        <div class="pull-right roundcontainer">
            <div class="round1"></div>
            <div class="round2"></div>
            <div class="round3"></div>
            <div class="round4"></div>
        </div>  

    </div>

    <ul class="dropdown-menu">

        <li><a href="#" class="effectbtn" >Messages</a> </li>
        <li><a href="#" class="effectbtn">Events</a> </li>
        <li><a href="#" class="effectbtn">Settings</a> </li>

    </ul>

</div> 

Additionally, here is the CSS styling for the above HTML code:

.dropdown-toggle.mytextformcontrol {
    width: 100%;
    cursor: pointer;
    overflow: auto;
}

.roundcontainer {
    position: absolute;
    height: 100%;
    width: 50px;
    right: 0px;
    top: 0px;
    background-color: #505ce5;
    overflow: hidden;
}


.round1,.round2,.round3,.round4 {
    position: absolute;
    border-radius: 100%;
    height: 30px;
    width: 30px;
    background-color: rgba(255,255,255,0.65);
    top: 50%;
    left: 50%;
    transform: translate(-50%,-50%);
}

.roundcontainer:hover .round1 {
    transform: scale(0.5);
}

.dropdown-menu {
    width: 100%;
    box-shadow: none;
    top: 125%;
    font-size: 18px;
    padding: 0px;
    border: none;
    background-color: #505ce5;
    border-radius: 0px;

}

.dropdown-menu:after {
    content: "";
    position: absolute;
    right: 40px;
    top: -20px;
    border-width: 10px;
    border-color:  transparent transparent #505ce5 transparent;
    border-style: solid;

}

.dropdown-menu li a {
    color: #fff;
    border-bottom: 1px solid #fff;
    padding: 20px;
    transition: all 0.2s;
}

.dropdown-menu li:last-child a{
    border-bottom: none;
}

.dropdown-menu li a:hover {
    color: #505ce5;
    background-color: transparent;
    z-index: 1;
}
.dropdown-menu li a.effectbtn:hover:before {
    z-index: -1;
}

Here's an image of the current UI design: https://i.sstatic.net/mVJNK.png

The issue I'm facing is that the up arrow generated with a pseudo-class loads after the dropdown menu slides down. How can I ensure that it loads prior to the dropdown menu sliding?

Answer №1

Consider utilizing the :before pseudo-element instead of :after

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

Scraping the web for dynamic data with the power of R

I am facing a challenge in retrieving the average user rating from an Indian movie Hindi review page on Times of India. The code I have written seems to be unable to fetch the desired data, which I suspect is due to the dynamic loading nature of the conten ...

How to implement Bootstrap 5 Floating Label in Contact Form 7 for maximum impact?

I'm having trouble with the new form feature, specifically Floating labels (Bootstrap 5) in Contact Form 7 on Wordpress. The issue arises when a <p> tag is added inside the <input> tag. It seems to break the functionality, but I'm not ...

``Why Ionic 3 Popover Sizes Should Adapt to Different Screen

Currently in my Ionic 3 project, I am utilizing a popover with a set height using the following code snippet: editOpty(rw){ let popover = this.editOptyPopup.create(EditOptyPopoverComponent, rw, { cssClass: 'edit-opty-popover'}); popover ...

"Step-by-step guide to show a calendar in a popup window

I am having trouble with displaying the calendar on a popup. I have created the popup and want to show the calendar within it. I've tried implementing the code but the calendar is not showing up. Any assistance would be greatly appreciated. Please che ...

How to trigger a horizontal scroll on load for a specific ID in HTMLDivElement

Looking for advice on how to make one of the horizontally scrolling DIV containers on a site scroll to a specific position onLoad. The challenge is that this particular container is located far down the page vertically, and we want it to scroll horizontall ...

URL Bootstrap Table Formatter - Enhancing Your Table Design

Javascript: function LinkFormatter(value, row, index) { return "<a href='"+row.url+"'>"+value+"</a>"; } HTML: <th data-field="snum" data-sortable="true" data-formatter="LinkFormatter" >LINK</th> <th data-sortable=" ...

How to perfectly center a text box in HTML

UPDATE: I have included the relevant JavaScript code. Essentially, a text box appears when a checkbox is clicked, but I want the text box to be centered on the page. I am attempting to center align a text box on the page, but I am struggling to achieve th ...

Is there a way to determine if the Acrobat plugin is installed and the web viewer setting is enabled using jQuery and C#?

Is there a way in jQuery or C# (as I am currently working on an .aspx page in Sharepoint 2010) to detect if the Adobe Acrobat plugin is installed and if the web viewer setting is enabled? I understand that the plugin is usually installed with Adobe Reader ...

Double Pop-up Issue with IE 11 - Two Consecutive Leave or Stay on this Page Prompts

This issue is specific to Internet Explorer. I have a webpage that contains a Close button. When the Close button is clicked with any unsaved changes on the page, a "Leave or stay on this page" popup appears. Clicking the Leave button functions as expected ...

Excess space creating horizontal and vertical scrolling issues on an HTML webpage

Currently, I am experimenting with CSS effects. In my code, I have included div elements to display balls on the document body, each with random sizes and colors. However, an unexpected issue has arisen - excess scroll space is being generated due to the c ...

JavaScript: When utilizing 'this' along with nextSibling, encountering the issue of undefined not being an object

When I run a function on the click of a button in my HTML, I want to retrieve the innerHTML value of the sibling element that was clicked. However, I keep receiving the error message 'undefined is not an object'. Here's how my HTML structure ...

Limiting the click event to the parent div only

I've encountered a problem with my overlay setup. I have an overlay with a child div inside, and I want the overlay to close only when the user clicks on the overlay itself, not the child div. Even though I've implemented the closing function, it ...

Text that adjusts its size based on the available space between columns within a row

I am currently developing an application using angular and bootstrap, and I have a requirement to insert a link between two columns in the third row of iteration. Here is what I have attempted so far: Html: <div class="container"> <div clas ...

Exploring the possibilities of toggling between a personalized CSS design and a Bootstrap CSS layout

Is it possible to implement a dropdown menu on my sample-page using javascript/jquery in order to switch between a custom layout and a bootstrap layout? ...

Sending two files to a Node server and retrieving a file through an ajax request

I need assistance with a process involving two file inputs and a button. When the button is clicked, I want to send the two files to the server for processing and then receive a new file as a result. HTML Structure <input id='file-input1' ty ...

Font Awesome Icons not displaying properly following implementation of GetSimple CMS

Seeking help with a problem I encountered. I successfully created a company webpage and integrated Font Awesome. The static version of the page, built using HTML5, CSS3, and jQuery, is working perfectly. However, when trying to integrate this static webpag ...

I'm having trouble getting my website to align in the center of the

Struggling to center my website no matter what I try. I experimented with different CSS properties but haven't had much luck. margin: auto 0; I also attempted the following: margin-left: 50%; margin-right: 50%; The closest I got was aligning every ...

Tips for inserting a line break into a string in Typescript

I am working on a group of buttons that display months. However, they are all currently showing on one line or row and I would like to put a break at the end of June so it displays on two rows. I have tried various methods such as 'June' + ' ...

Incorporate a Bootstrap panel featuring a stylish border design and perfectly centered text

I am attempting to design two panels in Bootstrap with centered text and different fonts. Similar to the layout shown in the image below https://i.sstatic.net/aVGwV.png Here is my code: <div class="row"> <div class="col-lg-6&q ...

Tips for preventing the hard coding of option values or inner HTML within a select menu when working on CS50 Finance

<select name="symbol"> {% for row in stocks %}} sym = row["symbol"] <option value=sym>sym</option> {% endfor %} </select> The current code snippet above displays a drop-down menu populated with stock symbols from a ...