Area of Interest - Underline

Check out this navigation menu: https://jsfiddle.net/LauraStoian/5kmo0v7e/.

body {
  border: solid 3px black;
}

#UL_1 {
  align-items: stretch;
  block-size: 103px;
  box-sizing: border-box;
  
  /* Additional CSS properties */
  
}


/* Styling for UL_1 */

#LI_2 {
  align-items: center;
  block-size: 103px;
  bottom: 0px;
  box-sizing: border-box;
  
  /* Additional CSS properties */
  
}


/* Styling for LI_2 */


<span id="SPAN_4">
    <!-- Custom styling -->
</span>

<!-- More spans and styles -->


/* Additional span styles */

<body>

  <ul id="UL_1">
    <li id="LI_2">
      <a href="http://index.html" id="A_3"><span id="SPAN_4"></span> <span id="SPAN_5"><span id="SPAN_6"></span> <span id="SPAN_7">Home <span id="SPAN_8"><i id="I_9"></i></span></span></span></a>
    </li>

    <!-- Additional list items -->

    </ul>
</body>

The hover effect on the links only applies to the text, not the surrounding area. The issue stems from the positioning of the border in relation to padding. While trying to expand the hover area, the positioning of the border becomes problematic.

To address this challenge, consider repositioning the elements or utilizing pseudoelements like ::after to create the desired effect without compromising the border placement. Experiment with different approaches to achieve a balance between hover functionality and visual aesthetics.

If you have any further questions or need assistance with implementation, feel free to ask for help!

Answer №1

To achieve the effect you are looking for, hover over your list item (LI) so that the inner span receives a border.

Check out the updated jsfiddle here

To make this work, simply update your CSS for the hover state as shown below:

#LI_2:hover #SPAN_5,
#LI_10:hover #SPAN_13,
#LI_16:hover #SPAN_19 {
  border-bottom-style: solid;
  border-bottom-width: 3px;
  border-bottom-color: red;
}

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

Eliminating the impact of a CSS selector

I have a complex mark-up structure with multiple CSS classes associated: classA, classB, classC, classD. These classes are used for both styling via CSS and event binding using jQuery selectors. The Challenge: I need the jQuery events to be functional whi ...

JavaScript: Can you clarify the value of this variable using five sets of double quotations?

Could you please review the code snippet below for me? <script type="text/javascript"> function recentpostslist(json) { document.write('<ul class="recommended">'); var i; var j; for (i = 0; i < json.feed.entry.length; i++) { ...

Concealing objects identified by a specific id

I have two separate div elements var promptContent = $('<div id="errorr">').addClass("formErrorContent").html(promptText).appendTo(prompt); var arrow = $('<div id="errorrarrow">').addClass("formErrorArrow"); I need to refe ...

Prevent the repositioning of a tooltip due to overflow in Bootstrap 5.2 and Popper JS Tooltips

Can someone please provide an example of how to create a tooltip using Bootstrap 5.x and Popper JS, where the tooltip remains fixed to the associated element even if the page overflows and scroll bars appear? I've attempted to work with boundaries an ...

Is there a way to automatically redirect my login page back to the original page in case of login failure?

I'm currently working on a basic login page using express.js + E.js. If the login credentials are incorrect, I have a variable badLogin that is triggered (see below). However, my goal is to redirect the website back to the login page instead of remai ...

Enhance your Datatables experience with the inclusion of a select form

Here is the code I am working with: Javascript: $(document).ready(function() { $('#example').DataTable( { "ajax": '../ajax/data/arrays.txt' } ); } ); HTML <select id="office-select" name="idOffice"> <op ...

Is it possible to switch the background-image after a gif has finished loading?

I am currently using a GIF as a background image, but I would like it to show a static image until the GIF is fully loaded and ready to play. After reading several similar discussions, I understand that you can manipulate elements with JavaScript once the ...

Ensure that the child div completely fills the entire width of its parent container,

My table contains another table within each row. I have implemented scroll overflow for the mobile view, but this causes the rows to not fill the available space and lose their background when scrolling. I have experimented with using width: fit-content a ...

Refresh gif without having to reload it in Internet Explorer 11

I'm attempting to create a feature where a gif restarts when clicked by the user, without needing to reload it (due to the heavy size of the gif which is preloaded for my application). The current code functions flawlessly on Chrome and other "modern ...

Adding the BETA symbol to your Bootstrap navbar is simple and can be done by

Is there a way to include a "BETA" symbol at the top of the "Brand Name" on my Navbar, similar to the "TM" symbol? How can this be achieved? ...

Adaptable/Responsive Layout

Thank you for taking the time to look at this post. I am currently working on gaining experience with html, CSS, and JavaScript in hopes of entering the Front End Developer field. Today, I encountered a few issues while working on this adaptive design. He ...

What are some ways to personalize a scrollbar?

I am looking to customize the scrollbar within a div. I attempted to modify it using the code below, but I encountered difficulties when trying to change the scroll buttons and did not achieve my desired outcome. Additionally, this customization did not wo ...

Expand the size of the bullets in unordered lists

What is the best way to customize UL list bullets to have a larger width without using custom images? ...

Ways to halt a script entirely once its tag has been eliminated

I have a script from a page tracker website that runs periodically. Occasionally I need to restart the script from the beginning. To do this, I typically remove the script tag from the DOM and then re-append it. However, because the script utilizes setInt ...

Ensure that containers of varying sizes are arranged properly using Bootstrap

I run a blog site that utilizes bootstrap for creating and posting content on an index page. Given the varying thumbnail sizes, there may be differences in length unless a standard image size is adopted. Here's how it would appear with a standard si ...

Picture fails to load on Ionic app on the device

Currently, I am utilizing Ionic 3 for my project. The location of the images file is \src\assets\img. This pertains to a basic page implementation. export class BasicPage { items = []; constructor(public nav: NavController ,private adm ...

Learn how to assign an ID to a React component in order to access it using the document.getElementById() method

After going through multiple inquiries, my understanding led me to believe that simply setting the id as shown below would suffice: <MyComponent id="myId"/> However, upon invoking document.getElementById() on the specified id, I receive a null resu ...

Could you offer assistance in resolving the error I am encountering with the collection.get() function?

I encountered an issue while trying to implement a database in my project. I imported 'collection' to use in my code. Here is the snippet: import { initializeApp } from "https://www.gstatic.com/firebasejs/9.0.2/firebase-app.js"; import ...

The side-nav in Materilize remains permanently open and does not have the option to load in a collapsed state

My sidebar navigation is not working as intended. I want it to load collapsed and display a modal, similar to the example in this fiddle: Here is the relevant code snippet: HTML: <header class="text-center"> </header> <div class="mai ...

Is your margin not functioning correctly? Is padding taking on the role of margin?

One issue I'm encountering is that the margin isn't behaving as expected in this example. The padding seems to be working like margin should. Why is that? Print Screen: https://i.stack.imgur.com/N1ojF.png Why is it that the margin in the h3 ta ...