Hovering over the <li> element reveals that it does not have an appropriate size

I'm currently utilizing bootstrap and have come across this code snippet:

<ul class="dropdown-menu scrollable-menu-brands" style="width:210px;">
    {foreach $arr as $id => $r}
       <li><a class="dropdown-item" style="font-size:15px;font-family: PT Sans Narrow,PTSansNarrow;" href="#">{$r}</a></li>
    {/foreach}
</ul>

Additionally, I have applied the following css styling:

.scrollable-menu-brands {
    height: auto;
    max-height: 320px;
    overflow-x: hidden;
}

.scrollable-menu-brands::-webkit-scrollbar {
    -webkit-appearance: none;
}

.scrollable-menu-brands::-webkit-scrollbar-thumb {
    border-radius: 8px;
    border: 2px solid white; /* should match background, can't be transparent */
    background-color: rgba(0, 0, 0, .5);
}

.scrollable-menu-brands li a {
    height: 10px;
    padding-top: 0px;
}
.dropdown-menu > li > a:hover{
    background-color: red;
;}

Upon hovering over an item in the list, I noticed that the background color only covers the top portion of the element. You can refer to this screenshot for clarification: https://i.sstatic.net/GyuH5.png

If anyone has insight into why the hover area is limited in height despite attempts to increase it not working, your input would be greatly appreciated.

Answer №1

@MathAng,

It appears that the height of your A and LI elements are not matching up correctly. The default height of the LI tag is 26 pixels, but in your CSS you have specified a height of 10 pixels for the A tag.

One solution could be to use the following CSS:

.scrollable-menu-brands li a {
    padding-top: 0px;
}

Instead of:

.scrollable-menu-brands li a {
    height: 10px;
    padding-top: 0px;
}

Alternatively, you could add height: 10px; to your LI tag like this:

.scrollable-menu-brands li {
    height: 10px;
}

Hopefully one of these suggestions resolves the issue for you!

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

One particular page is having trouble loading CSS, whereas it loads perfectly fine on a different page

I have two pages, 403.html and 404.html, both of which need to load the same style.css file. Strangely, when I visit the 403.html page, the CSS loads perfectly fine. However, when I navigate to the 404.html page, even though it has identical code with only ...

Getting rid of the <br> tag as well as the linked <span> element

I've been experimenting with creating dynamic forms. My latest project involves a text box, an 'Add' button, and a div. The idea is that whenever a user types something into the text box and clicks the Add button, that value should appear in ...

Encountering issues with implementing useStyles in Material-UI components

Currently, I am working on a project utilizing Material-UI's library and encountering styling issues. This project marks my initial venture into ReactJS and JavaScript in general. Therefore, any assistance would be greatly appreciated! I am struggli ...

Using an image as a dropdown menu in HTML: A step-by-step guide

I am facing a challenge in creating an HTML/CSS button that should display a dropdown when hovered over, but unfortunately, it's not working as expected. Here is the link to the code. .Panel { overflow: hidden; width: 25%; height: 100%; co ...

Leveraging the Power of SASS Variables Across Your Entire NativeScript Application

Currently, I am in the process of developing an app using NativeScript 6.4.1 along with Angular 8. In order to enhance my styling capabilities, I have decided to incorporate SASS due to its advantageous features like variable names. My designer has suppli ...

Display the delete message URL according to the user's name

I have a wall message system using PHP and jQuery where messages from all users are displayed. Now, I want to add delete functionality to each message, but the delete link should only be visible to the user who posted the message. .childs { opaci ...

Troubleshooting CSS Carousel Navigation Problems

{% extends 'shop/basic.html' %} {% load static %} {% block css %} .col-md-3 { display: inline-block; margin-left:-4px; } .carousel-indicators .active { background-color: blue; } .col-md-3 img{ width: 227px; ...

Is it possible to modify an HTML element when hovering over it in an ASP.Net page?

Is there a way to use jQuery to show the child span text - SomeClassChild3 string when hovering over the parent div - SomeClassParent in an aspx page? Here is the JavaScript section of the code: function ShowDiv(Somedata){ for(var v in Somedata){ va ...

During the rendering process, the property "instance" was attempted to be accessed but is not defined

I am having trouble creating a Contact Us page using v-model. My code keeps throwing these errors: Property "inputted_name" was accessed during render but is not defined on instance Property "inputted_email" was accessed during render but is not defined o ...

avoid triggering the on hover state

When working with jQuery, I have a CSS style targeting a specific div: div.right-sm:hover{background-color: blue} Now, I am trying to prevent the hover effect using jQuery: $(this).parent('div').removeClass('right-sm:hover'); Howev ...

The hamburger icon refuses to close even after being clicked once

Navigation Bar Component import { Link } from 'react-router-dom'; import { connect } from 'react-redux'; import PropTypes from 'prop-types'; import { logout } from '../../redux/actions/auth'; import './Navigati ...

Overlap one element entirely with another

Currently, I am working on a way for an element called overlayElement to completely cover another element known as originalElement. The overlayElement is an iFrame, but that detail may not be significant in this scenario. My goal is to ensure that the over ...

"Fixing index.html with the power of Bootstrap 4: A step-by

*I am facing an issue where the default bootstrap navbar style appears before my custom styles get applied every time I reload the page. Any assistance would be greatly appreciated* - Whenever I reload the page, the default bootstrap navbar style appears ...

Issue with QT Creator when compiling HTML5 application

Recently, I have set up QT Creator 2.7.0 [Based on Qt 5.0.1 (64 bit)] on my Ubuntu 13.04 system. A problem arose when attempting to create a sample HTML5 Application and run it, resulting in issues during the build process. Below is the output generated: ...

Various lists do not appear directly under each other

Hello everyone, I recently created a webpage displaying different lists of football players. My goal is to keep the lists stacked vertically without any floats that would make them appear side by side. The separate lists are essential for properly categori ...

Trouble loading antd's less styles

In my NextJs project, I have the following file structure: -pages -_app.tsx -app -styles -antdstyles.less Within _app.tsx, I am attempting to import @styles/andstyles.less, which simply imports antd styles like this: @import '~antd/di ...

Adjust the div container to wrap underneath the image if the webpage width decreases

Hello there, I am currently in the process of creating my own portfolio. I have a brief introduction that I would like to display next to an image of myself, with the image positioned on the right side. I have a div called "container" which contains anoth ...

Designs for an HTML5 Cheeseburger navigation interface

I've been struggling to implement a functional and visually appealing hamburger menu on my website. The challenge lies in integrating the menu seamlessly into the page rather than having it just pop up abruptly. Despite trying various webkit tools, I ...

Is it possible to incorporate a React app as a component within a static HTML page?

Looking to integrate the react-csv-viewer component into a static HTML page without deploying it on a local server. I've tried following the instructions from the React tutorial, but am struggling with the build process. My goal is simple - to use th ...

A versatile jQuery function for extracting values from a :input selector

Is there a universal method in jQuery to retrieve the value of any :input element? I pose this question because I have a webpage containing select and checkbox inputs, as seen in the code below: for (var i = 0; i < arguments.length; i++) { ...