What is the best way to ensure that the text on the sub menus in the recipes navigation bar is displayed in vibrant colors?

Can anyone help me figure out how to make the blue hover effect fit perfectly with the subheadings in my recipes menu? Right now, the color doesn't cover the text fully. Feel free to read and run my code for a better understanding.

This is the CSS I'm using:

nav li:hover ul {
    display: block;
}

Here is the link for reference:

https://jsfiddle.net/harisfaisal/q68n7ro4/2/

Answer №1

The issue lies in your code where nav li {width:20%} is impacting all li elements, including submenus, causing the color to only cover 20% of the submenu. To resolve this, you can simply add width:100%; to your nav li li {} selector.

It's worth noting that your code contains repetitive selectors, which can be combined for better readability and efficiency.

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

Enhance user experience by enabling clickable links in Angular comment sections

Currently, I'm developing an application that allows users to add comments to specific fields. These comments may contain links that need to be clickable. Instead of manually copying and pasting the links into a new tab, I want the ability to simply c ...

The method for transforming all headers into permalinks with jquery/javascript

I am looking for a way to transform all headers on a page into clickable permalinks using jQuery or JavaScript. Here is the HTML code: $('h3').each(function() { var id = $(this).attr('id'); if (id) { //Check if the element has a ...

The HTML output from converting Tiny MCE text content is not rendering properly on the React app's front-end

I'm currently working on a blog project using React and Material UI. In order to enable users to add posts, I've integrated a TinyMCE rich text editor onto the page. The issue arises when trying to display a specific blog post, as the content app ...

Struggling to vertically center ion-search bar within Ionic header section

I'm really struggling to center an ion-searchbar within my navigation bar. I've experimented with text-align and ion-grids, but nothing seems to be effective. It has to be the component itself. https://i.sstatic.net/OWDPZ.png index.html <io ...

The JavaScript function document.getElementById.onclick is not functioning as expected

One issue I am facing involves counting all downloads on my website. My current approach is to increment a value in my database each time a download button is clicked, and then display this value. Despite trying multiple methods, the download count always ...

Discovering the present width of an Angular element after it has been eliminated

Imagine you have a horizontal navigation bar coded as follows: HTML: <ul> <li ng-repeat="navItem in totalNavItems">{{name}}</li> </ul> CSS: ul, li { display: inline-block; } The data for the navigation items is fetched from thi ...

Center alignment of all the flex items on the display

In order to achieve my desired effect, I have red elements that must be displayed as flex and cannot be changed. I want to place text above the middle of these red elements. The expected result is shown in this image: https://i.sstatic.net/w3cQS.png Curr ...

Set a placeholder for the editable div if it does not contain any text

Currently, I am attempting to create an editable div with a placeholder. My goal is for the placeholder to be automatically displayed when there is no text in the div. To achieve this, I am using the contentEditable='true'; attribute on the div ...

A fixed header for tables that shifts along with horizontal scrolling

Seeking assistance with a persistent issue - I have a table with a fixed header on vertical scroll (see CSS and Javascript below), but the header fails to move horizontally when I scroll. window.onscroll = functi ...

Implementing a persistent header on a WordPress site with Beaver Builder

My website URL is: . I have chosen to use beaver builder for building and designing my website. I am in need of a fixed header that can display over the top of the header image. Here is the code snippet that I currently have: <div id="header">html ...

What is the best way to format a description list with bullet points?

I need to style a <dl> description list that is unordered, so I want bullets before each <dt>. Edit: Just to be clear, I have an unordered list of <dt>-<dd> pairs. They should look like one list item, with the <dt> having a b ...

How can you position navbar links to the right in Bootstrap?

I have been given an assignment that requires me to create HTML code to replicate a specific webpage design, which can be viewed here: https://i.sstatic.net/GC68r.png One of the requirements is to align the Home, Contact, About Us, and Messages links to t ...

What is the best way to decrease the opacity of a div so that it is lower than the

I am looking to create a sign-up form that greys out the background page and places the form in the center using an iframe. Here is the code for achieving this: code: <div id="cover5"> <iframe name="warning" src="SignIn.php" id="warning" st ...

Embed a variable into an HTML element without affecting the inner HTML content

I am trying to inject a specific string into an HTML tag <td anyElement="{{myString}}" >some random text here </td> My desired interpretation is as follows: <td anyElement='Some string'>some random text here </td> Howe ...

Comprehending the importance of a selector in a dropdown menu

Trying to figure out how to create a drop-down menu from CSS tricks, I found this code snippet: <nav role="navigation"> <ul> <li><a href="#">One</a></li> <li><a href="#"&g ...

A guide on Extracting Values from Nested Objects

Although I am not well-versed in JavaScript, I have a small project where I need to use JavaScript. I am attempting to retrieve values from an object nested within another object. However, my code is throwing errors. Below is the snippet of my code with d ...

Zoom in and Zoom out functions in ngPdf with centered view

I have incorporated the pdf canvas to showcase PDFs on my AngularJS/Bootstrap application, and I must say, the preview feature is working exceptionally well. However, one thing that I would like to achieve is centering either my modal or the canvas itself ...

Connected selection menu

I have noticed several discussions on this topic, but many of them rely on JavaScript or focus solely on a standard drop-down list. I have developed a PHP function that generates drop-down menus based on select queries in my database. Currently, this part ...

Getting the value of a CSS Variable from Radix UI Colors with Javascript/Typescript: A step-by-step guide

Currently, I am attempting to dynamically retrieve the Radix Colors values in JavaScript. The reason for this requirement is that I generate these colors based on user input, resulting in values that are variable. As a result, I cannot hardcode the values. ...

Print out - find elements by class name in the console

I'm currently learning how to use HTML5 Drag and Drop. I have a table created with PHP that generates HTML elements. echo "<li class='elements' id='".$row['id']."' draggable='true'>".$row['element_n ...