Changing the animation associated with a hover action - tips and tricks!

My navigation header includes links to various websites, some of which are displayed as drop-down menus. I have implemented an animation and style change on hover to visually indicate the active link and display all available options in case of a dropdown menu. However, after showing the dropdown menu, the styling and animation applied to internal links remain consistent with the main links, resulting in the underline always appearing in the same location rather than below each individual link. Thank you for your time and assistance. Here is an example link demonstrating the current behavior:

Example Link

Template snippet:

<div id="row">
        <div class="col-xs-12">
            <header>
                <nav class="navbar navbar-expand-lg navbar-light header">
                 
                  
                  <div class="collapse navbar-collapse" id="navbarNav">
                    <ul class="navbar-nav menu">
                      <!-- Navigation links go here -->
                    </ul>
                  </div>
              </nav>
            </header>
        </div>
    </div>

CSS styling:

<!-- CSS styling goes here -->

Answer №1

Don't forget to include this in your script

.menu-link {
   margin-bottom:5px;
   position:absolute;
}
.menu-item {
   position:relative;
}

Update the following code: bottom:50%; to bottom: 10px;

.menu-link:before {
    bottom: 10px;
}

Make sure to take a look at this live example on CodePen: https://codepen.io/SaraJones/pen/abCDefG

Answer №2

To achieve the desired effect, apply the CSS property position: relative to the class .dropdown-menu-item and specify a specific position for the pseudo-element .dropdown-menu-item:before, such as 0px from the bottom.

Alternatively, if you prefer the positioning to be relative to the link, add position: relative to the class .dropdown-menu-link.

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

How can I align the kendoMenu in the center when the menu width is unpredictable?

Presenting a modified menu structure: <html class="k-webkit k-webkit40"> <head> <title>Site Title</title> <!-- js and css files referenced here --> </head> <body> <link h ...

What is the best way to extract value from an input text that is being repeated using ng-repeat within a Tr

Having a table with repeated rows in angular, you can also dynamically add new rows by clicking a button. If there are already 3 repeated rows and 2 extra rows are added with data entered, how can we retrieve all the data from the table in the controller ...

AngularJS 1: Dynamically updating input values in real-time

Hey everyone, I'm experimenting with Angular and have encountered a roadblock. I am trying to assign values to an input element using ng-repeat for a list of parameters. <input type="text" ng-model="parameters.inParameterName" class="form-control ...

Adding design elements to HTML 5 components

Are there any potential downsides to applying CSS to the <section>, <header>, <article>, and <footer> elements? I vaguely remember reading somewhere that these elements should not be styled, but I can't seem to locate the sourc ...

Content in Tab Fails to Load due to IFRAME URL

On my web page, I have embedded an IFRAME with its src attribute set to load HTTPS content. This IFRAME is placed within a Bootstrap Nav-Tab Content, which in turn is located inside a Card element. Upon loading the webpage, I noticed that the content does ...

Turkish text is not appearing correctly on the UIWebview when embedded in HTML

One of the challenges I encountered in my iOS project involved programming a UIWebView to load content in both English and Turkish from a web service. To accomplish this, I formatted the HTML string with the necessary headers and saved it locally before pr ...

How can I preselect an item in a dropdown list in HTML using the result of an SQL query

Is this the correct method for setting a default value in an HTML drop down menu? The variable $vendor_name is determined by retrieving an array of results through a query, which is then looped to generate table rows in HTML. Consequently, the value of $v ...

jQuery Animation Issue: SlideDown Effect Not Working as Expected

I'm feeling quite confused about this situation. I've been attempting to utilize the slideDown function in jQuery, but when I click on the 'information' div, it just jumps instead of animating smoothly. I suspect that one of the cause ...

Inspecting element value on a website

On a marketplace website, I extracted the attribute (capacity_gold) from a table. Since the values are dynamic and constantly changing, I aim to develop a basic script that will notify me when the attribute value exceeds 100. The current value of the attr ...

Can you recall the name given to characteristics that do not have any value assigned to them (e.g. "checked" and "selected")?

There is a specific group of attributes in HTML that do not accept a value. For example, the checked attribute for the <input> tag and the selected attribute for the <option> tag fall into this category. Do you know what term is used to refer ...

An illustration of the fundamental concepts of require.js

main.md <markdown> <head> <script data-main="script" src="http://requirejs.org/docs/release/2.1.8/minified/require.js"></script> </head> <body></body> </markdown> script.css defi ...

What is the best way to keep a header row in place while scrolling?

I am looking to keep the "top" row of the header fixed or stuck during page scrolling, while excluding the middle and bottom rows. I have already created a separate class for the top row in my header code: view image description ...

How to utilize Bootstrap 5 flex for aligning text in the center position

Within these specific divs: <div class="col-6 col-md-4 col-lg-3 col-xl-2 my-3"> <a href="#" title="Falazóhabarcs" class="main_category d-flex justify-content-between align-items-center radius p-3&quo ...

What is the best way to deactivate a hyperlink of an <a> tag specifically for a particular child within an element?

Imagine you have a clickable container that leads to another page when clicked. However, there are elements within this container that you want to disable so that clicking on them does not activate the link. How can this be achieved? For instance, ...

I am eager to showcase a Pokémon image sourced from the API, but I am faced with the challenge of only having the image URL and not knowing how to display it effectively

As a beginner in programming, I am seeking some assistance. I have been able to retrieve a random Pokémon from an API and gather its data, including the ID, name, and picture. My main focus now is to display the image of the Pokémon in the custom modal I ...

Creating a Rest API URL in Vue.js by extracting form values

I just finished coding this Vue component: <template> <div> <h2>Search User By ID</h2> <input v-model="userId" type="number" placeholder="modify me" /> <br /> <p v-if="userId.length != 0"> ...

Email sent upon form submission

Users have the option to provide feedback through a simple form below. Upon submission, the feedback will be sent directly to my email address. The subject line of the email will automatically read "Feedback from [name input]" and the email will show it&ap ...

What's preventing the buttons from shifting positions?

Having some trouble with my Minesweeper Web Game setup. My buttons are stuck in place and won't budge. Can someone help me figure out what's wrong? Here's the code snippet I've been working on (FYI, using NetBeans 8.1 IDE) HTML: <! ...

How to make a HTML div background fill the entire page

Is there a way to extend the background in a div so that it adjusts to fit the screen resolution? I also want to include a navigation bar at the top right corner of this div for the intro page. There will be additional content in other divs positioned be ...

What is the best way to display data from an Excel spreadsheet on my website?

I'm faced with a challenge in my Excel spreadsheet- I have a mix of numbers and text that I want to turn into graphical representations on a webpage. I'm considering using Python or PHP to achieve this as HTML alone doesn't seem up to the ta ...