Modify individual list item attributes

I have been attempting to modify the background of the list item labeled as home in order to ensure that it displays hover properties even when not being interacted with. Despite specifying this in the class, the appearance does not change.

Below is the HTML code:

         <div id="header">
     <img id="logo" src="images/logo.jpg">
     <ul>
     <li> <a href="#">CONTACT</a> </li>
     <li> <a href="#">GALLERY</a> </li>
     <li> <a href="#">EVENTS</a> </li>
     <li> <a href="#" class="currentpage">HOME </a> </li>
     </ul>          
     </div>

This is the CSS script used:

       #header ul {
        padding-top:1em;
          }

       #header ul li a.currentpage {
        color:white !important;
        background-color: #F96E5B !important;
       }

       #header ul li a {
        text-decoration: none;
        color:#676767;
        font-family: 'Oswald', sans-serif;
        font-size: 1em;
        float:right;
        line-height: 3em;
        padding-right: 1em;
        padding-left:1em;
           }

          #header ul li a:hover{
      background-color: #F96E5B;
          }

You can check out the website at

Answer №1

you should definitely give this code a shot

<li>
<a  class="menu-item" href="#">ABOUT</a>
</li>
<li>
<a class="menu-item" href="#">WORKS</a>
</li>
<li>
<a class="menu-item" href="#">SERVICES</a>
</li>
<li>
<a class="menu-item" href="#">HOME </a>
</li>

style the menu items with this css

#header ul li a.menu-item:hover
{background-color: #F96E99;
color: white;}
#header ul li a.menu-item:hover
{background-color: #F96E22;
color: white;}
#header ul li a.menu-item:hover
{background-color: #F96Eaa;
color: white;}
#header ul li a.menu-item:hover
{background-color: #F96E55;
color: white;}

Check out the demonstation here: http://jsfiddle.net/Y9Rb6/1/

Make sure to assign separate classes and hover functions for each menu item. Hope that helps!

Answer №2

Upon reviewing the code provided in the page/link you shared, it appears that the intention is to modify the background color of the anchor tag associated with the element identified by id="selected"

To achieve this effect, you can apply the following CSS rule:

#header ul li a#selected {background: red /* or any preferred color */ }

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

Mastering the placement of script tags in your Next.js application with Next Script

I'm in the process of integrating a third-party script into my Next.js website. This particular script adds an iframe right below its corresponding script tag. Therefore, it is crucial for me to have precise control over the placement of the script ta ...

What is the best way to adjust my carousel so that it occupies just 60% of the screen, allowing the panels beneath it to utilize the remaining space

How can I adjust the size of the carousel to occupy only 60% of the screen without the need for scrolling, allowing the panels directly below to fill the remaining 40%? The images within the carousel should resize accordingly based on the desktop screen si ...

Manipulate a table using Jquery's find() method to insert a cell populated with information from an array using before()

My current challenge involves inserting a column of cells with data from an array. Despite attempting to use a for loop, all the cells end up displaying the same data from the array. What I really want is for each new cell to show 'row_header1', ...

Initiate a click event on an anchor element with the reference of "a href"

I'm currently facing an issue with clicking a href element on my HTML website. The click event doesn't seem to be triggered. CODE: HTML CODE: <div class="button" id="info" ></div> <ul id="game-options"> <li><a ...

Adjust the scroll position when the height of a div is modified

Imagine we have a large div A with a height value and below it are other divs B, C, and more. If the user is viewing divs B or C, and A reduces its height by half, the scrolling position will remain the same. However, divs B and C will move up by that amo ...

A pair of buttons each displaying a unique div block

I am facing an issue with my jQuery script. I want to be able to click on one of the previewed text associated with a button and then have the other one close automatically. The desired effect is for the text to slide down using slideDown() and disappear ...

Iterate over JSON dates in JavaScript

Trying to utilize JavaScript in looping through a JSON file containing time periods (start date/time and end date/time) to determine if the current date/time falls within any of these periods. The provided code doesn't seem to be working as expected. ...

Investigating the Hierarchy of CSS Selectors

I've been pondering this question: What exactly is the functional distinction between these two code snippets, if any? I'm not certain how the use of a comma impacts statements. Does the #page > have an influence on the link in the first examp ...

Adding a class to the following DIV and smoothly transitioning the current one out can be achieved using a dynamic number of items in multiple instances

Is there a way to create a scalable CSS slideshow for text divs without using images? Here is the current HTML structure: <div class="mb-panel-container cf"> <div class="mb-panel-section mb-slider"> <div class="mb-panel active" ...

Bootstrap4 lacks responsiveness

html, body { background-color: #E3E3E3; width: 100%; height: 100%; margin: 0; padding: 0; } /* Custom Styling */ .section1 { background: url("../images/laptop-table1920-gray.jpg") no-repeat center center fixed; -webkit-background-size: cover ...

Having trouble with this code// Does anyone know how to make the div slide in line with other divs when hovering over it?

After spending countless hours analyzing and trying various solutions, I have come to the realization that I need to seek help with my code. The task at hand is proving to be incredibly frustrating, and I have exhausted all other options before resorting t ...

Only half of the image is responsive to hover effects

Just starting out with coding and running into an issue... My social media icons are supposed to turn pink on hover using a second image, but for some reason it's only showing up on the bottom half. Any suggestions? CSS: a.twitter:hover { backgr ...

Align a button to the left or right based on its position within the layout

On the left side, there is dynamic text and on the right side, a button is displayed as shown below: <div class="dynamic-text"> {{ dynamicText }} </div> <div class="some-button"> < ...

Utilize JQuery's .append() method to insert a new element into the DOM and then trigger an "on click" event within

I am attempting to use the .append() method to add a new radio button, and then when I click on the new radio buttons, trigger a new function. However, I am having trouble achieving this with my current code: HTML: <label>Where should the photo be ...

Problem with the spacing in the Bootstrap website after the breadcrumbs due to flexbox issues

I'm facing a challenge with one of my Bootstrap-based pages that I can't quite figure out. We recently implemented breadcrumbs for navigation, which is also built with Bootstrap. However, some pages are displaying a significant gap between the br ...

Modify how various classes are shown when hovering over a pseudo class

This is my customized scss code .image-container { position: relative; .delete-image { display: none; position: absolute; top: 0px; right: 0px; } .make-primary { display: none; position: absolute; ...

Display an image when the iframe viewport is reduced in size by utilizing media queries

I am looking to showcase a demo.html page within a 400px square iframe. When the viewport is smaller than 400px, I want demo.html to only display an image. Then, when clicking on that image in demo.html, the same page should switch to fullscreen mode. Sim ...

There seems to be a glitch with the Flask flash messaging feature, as

My Flask application includes login and register routes where I aim to display flash messages when username passwords are not matched. Specifically, this issue arises in my index and login routes: @app.route('/') @login_required def index(): ...

Is the CSS content-visibility property compatible with background images?

Can CSS content-visibility and contain-intrinsic-size also be used with the background-image property, or do they only work with IMG tags? Will either of these properties have any impact on the following code snippet? <span id="image"> #i ...

full-page overlay is covering the entire screen

Is there a CSS-based solution to create an overlay that remains visible even when the page is scrolled down? I want to use this overlay behind a popup. Using JavaScript to set the height of the overlay based on the page's content is one option, but I& ...