When hovering over the menu list, the background-color of the text area remains the same

I am facing an issue with my list menu.

The hover effect changes the background color only in the box area, but not in the text area.

I would like to figure out a way to make both areas change color on hover:

Here is the code snippet:

<div class="services">
                <ul>
                    <li class="general"><a href="" title="" >General</a></li>
                    <li><a href="" title="" >Marketing and Brand Strategy</a></li>
                    <li><a href="" title="" >Events and Launches at Exhibitions</a></li>    
                        <li><a href="" title="" >PR / Press releases,</a></li>
                    <li><a href="" title="" >Distribution and sales</a></li>
                    <li><a href="" title="" >Media and social media</a></li?
                </ul>
            </div>

CSS styling:

.services ul { display: block; padding: 0; margin: 0; }
    .services ul li{ list-style-type: none; background: #ffffff; line-height: 47px; border-top: 1px solid white; font-size: 12pt; width:350px  }
    .services ul li:hover{ list-style-type: none; background: #efefef; line-height: 47px; border-top: 1px solid white; font-size: 12pt; }
    .services ul ul:hover >a{ list-style-type: none; background: #efefef; line-height: 47px; border-top: 1px solid white; font-size: 12pt;  }
    .services ul li a{ width:100%; color: black; padding: 0 12px; font-family: 'Lora', serif; font-size: 12pt; text-decoration: none;background-color:#ffffff }
    .services ul li a:hover{ width:100%; color: black; padding: 0 12px; font-family: 'Lora', serif; font-size: 12pt; text-decoration: none;background-color:#efefef; }

View the example on jsfiddle: http://jsfiddle.net/r8rns8gw/1/

Answer №1

Eliminate the background-color:#ffffff; from .services ul li a - VIEW DEMO

CSS:

.services ul { display: block; padding: 0; margin: 0; }
    .services ul li{ list-style-type: none; background: #ffffff; line-height: 47px; border-top: 1px solid white; font-size: 12pt; width:350px  }
    .services ul li:hover{ list-style-type: none; background: #efefef; line-height: 47px; border-top: 1px solid white; font-size: 12pt; }
    .services ul ul:hover >a{ list-style-type: none; background: #efefef; line-height: 47px; border-top: 1px solid white; font-size: 12pt;  }
    .services ul li a{ width:100%; color: black; padding: 0 12px; font-family: 'Lora', serif; font-size: 12pt; text-decoration: none; }
    .services ul li a:hover{ width:100%; color: black; padding: 0 12px; font-family: 'Lora', serif; font-size: 12pt; text-decoration: none;background-color:#efefef; }

Answer №2

Try removing the background-color property for the <a> tag. Remove it from the last two lines of your CSS and see if that solves the issue.

    .services ul { display: block; padding: 0; margin: 0; }
    .services ul li{ list-style-type: none; background: #ffffff; line-height: 47px; border-top: 1px solid white; font-size: 12pt; width:350px  }
    .services ul li:hover{ list-style-type: none; background: #efefef; line-height: 47px; border-top: 1px solid white; font-size: 12pt; }
    .services ul ul:hover >a{ list-style-type: none; background: #efefef; line-height: 47px; border-top: 1px solid white; font-size: 12pt;  }
    .services ul li a{ width:100%; color: black; padding: 0 12px; font-family: 'Lora', serif; font-size: 12pt; text-decoration: none;}
    .services ul li a:hover{ width:100%; color: black; padding: 0 12px; font-family: 'Lora', serif; font-size: 12pt; text-decoration: none; }

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

Issue with mouseout gap in Microsoft Edge when using the <select> element

A noticeable gap appears in Microsoft Edge between the <select> menu and its options when expanding the menu, as shown here: https://i.stack.imgur.com/SprJ2.png This particular issue can cause problems with the mouseout event due to inconsistent be ...

how can I modify the css style of an html element only when a specific sibling is present?

After searching through the MDN CSS documentation, I was unable to find any Combinators that can target the specific element I want to style. /* second-span red when first-span is present */ [first-span] ~ [second-span] { color: red; } /* firs ...

Tips for adjusting text to fit within a container without needing to use overflow:auto

Is there a way to prevent text overflow in a container without using the overflow:auto property? I've come across plugins that automatically reduce the text size, but I'm not keen on that solution. What I want is for long words or URLs to wrap on ...

What is the best method for adjusting height in MaterialUI components?

Is there a way to remove this white line from the image?view image here When I set the height to 100%, it appears like this:view image here ...

Error: Unable to locate module 'next/font/google/target.css'

After setting up Next.js version 14.0.1 on Node.Js v20.9.0 and Ubuntu 20.04, I encountered an error right from the start. Failed to compile /var/www/html/C#/nextApp/app/layout.js Module not found: Can't resolve 'next/font/google/target.css?{&quo ...

Dynamic parallax or stacked vertical text animation

I am attempting to replicate the text effect found on . The text is centered both vertically and horizontally within each div, but as you scroll down, the top position shifts creating a parallax effect. As you continue scrolling, the text transitions to th ...

Contrast two distinct Python lists with different syntaxes

Being relatively new to Python, I am looking to compare elements from two separate lists. a=[] b=[] with open('dump.sql', 'r') as dump: for line in dump: if string1 in line: tail1 = line.split(string1)[1] ...

Does CSS positioning change depending on the screen size?

I need help fixing the positioning of my logo on the screen. I want it to be 40px from the top and centered horizontally regardless of the screen size. Here is the code that I have: <html> <head> <style type="text/css> body{ back ...

Adding a CSS style to specific sections of a string that is quoted in a Razor ASP.NET file

Is it possible to format a specific part of a string? I'm trying to only stylize the word within quotation marks. This is my cshtml code: { <div class="h-44 overflow-auto text-left mx-4 mb-4"> <p ...

When I view the website on a tablet in landscape mode, the navigation bar vanishes

I just finished creating a responsive menu for a website. Here's how it works: when viewing the site on a regular browser with a width less than 768px, the navigation menu items are stacked and hidden. To reveal them, the user needs to click on a tog ...

NextJS application failing to display SVG icon in the absence of internet connection

https://i.stack.imgur.com/M9reE.jpg https://i.stack.imgur.com/Yyg4g.jpg Upon inspection of the provided images, it is evident that the src URL points to a location within the nextjs public folder. The issue arises when there is no internet connection - i ...

Adjust SVG Checkbox to eliminate any unnecessary padding

I am attempting to customize the MUI5 checkbox CSS fields, and here is the current status: https://i.stack.imgur.com/BROpS.png These are my CSS classes: MuiCheckbox: { styleOverrides: { root: { ".MuiSvgIcon-root": { backgro ...

The issue of conflicting stylesheets is causing alignment and height discrepancies when using multiple icons

Is there a way to align icons from different stylesheets to have the same height? When attempting to use icons from separate stylesheets, I encountered a height issue where one icon left space at the top and bottom while another appeared correctly aligned. ...

Creating a list containing key-value pairs from a dictionary in Python

Looking for assistance on how to create a list with two indexes: The key and the corresponding value of a randomly chosen dictionary pair. Here is what I have tried using Latin words: d = {} d['house'] = "domus, domus" data1 = d.items() data = r ...

Ways to modify the screen when a click event occurs

To make the display block when clicking this icon: <div class="index-navi-frame-box"> <p onclick="expandFunction()"> <i class="fa fa-bars"></i> </p> </div> Here is what it should change to: <div class=" ...

Determine the position of an element in relation to a specific ancestor using JavaScript

Let's consider the following example of HTML code: <div id="site_header_container" class="site_bar_container"> <div id="site_header"> <div id="header_logo_container"> <a class="sliced" id="header_ ...

Responsive design is causing issues with the stacking of rows in Bootstrap

Currently in the process of creating a website using HTML5, CSS3, and Bootstrap technologies. Encountering difficulties while attempting to establish a stacked row-column layout. On desktop view, the design appears as desired, resembling this example: Th ...

What methods are available for updating the href color of an element using the DOM?

I am looking to update the color of a tab (Mathematics-tab) based on the value of 'aria-selected' changing to true in Bootstrap. I have multiple tabs, including one for mathematics, and I want to visually differentiate between selected and unsele ...

Create a layout with a single column that features a dynamic image, paired with another column housed within a modal using Bootstrap

I'm facing a design issue with a row that has two columns - one with an image and the other with a list of users in a modal window. As more users are loaded when scrolling down the modal, I want the image to remain fixed in its position. Here's t ...

Tips for creating a hover effect on an icon within a CSS grid

I've just started learning to code and wanted to create a component for previewing/displaying a project I'm working on. I've been attempting to add a hover effect to my links such as the GitHubIcon and LaunchIcon, but so far, it's not w ...