Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6354483
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T22:34:58+00:00 2026-05-24T22:34:58+00:00

I have a navigation bar with images, like so: <ul> <li class=me> <span class=cont><img

  • 0

I have a navigation bar with images, like so:

<ul>
  <li class="me">
    <span class="cont"><img src="dummy.png" /></span>
  </li>
  <li class="me">
    <span class="cont"><img src="dummy.png" /></span>
  </li>
</ul>

On hovering over a list item I want to change the background color to cover the span and image like so:

.me {background-color: none;}
.me:hover {background-color: rgba(150,150,150,0.5);}

Problem is, the image does not get covered… Is this because the background is in fact… a “background” on which child elements are sitting? If so, how could I achieve this effect with plain CSS?

EDIT – solution

this worked with my original HTML structure:

<ul>
  <li>
   <a href="" class="ui-btn">
     <span class="ui-btn-inner"> /* CONTAINS IMAGE AS BACKGROUND */
        <span class="ui-btn-text">text</span>  /* GETS BACKGROUND */
        <span class="ui-icon"></span>
     </span>
   </a>
 </li>
</ul>

“Negative logic”: If I assign the background to list item, it sits behind all child elements, so I figured I needed to assign the background to an element that is a child of the element containing the img to have it appear above all items. span ui-btn-inner contains the image, so setting the :hover background on span ui-btn-text makes it appear above the image… weird, but works.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T22:34:58+00:00Added an answer on May 24, 2026 at 10:34 pm

    Yes, it’s because the background is in fact a background. The best method to achieve this in raw css would be to continue using the background:

    .me
    {
        background-color: none;
        background-image: url(dummy.png);
        background-repeat: no-repeat;
    }
    .me:hover
    {
        background-color: rgba(150,150,150,0.5);
        background-image: ;
    }
    

    You could also achieve this effect with a bit of javascript as well.

    <ul>
      <li class="me">
        <span class="cont"><img="dummy.png" onmouseover='this.src="sometransparent.gif";' onmouseout='this.src="dummy.png";'></span>
      </li>
      <li class="me">
        <span class="cont"><img="dummy.png"" onmouseover='this.src="sometransparent.gif";' onmouseout='this.src="dummy.png";></span>
      </li>
    </ul>
    

    Code not tested. It might require tweaking to get it just right.

    Edit: Layering concept
    None of this pseudo-code is test, but I’ve done it before so it may just take a bit of tweaking. I don’t have a copy of the original I did on hand so I’ll have to wing it. The first step is to create a relative container and 2 sub containers.

    .meContainer
    {
        position: relative;
        width: 100px;
        height: 30px;   /* I usually specify height/width for these things */
    }
    
    .meContainerLink
    {
        position: absolute;
        top: 0;
        left: 0;        /* You need to use position to get them to overlap */
        z-index: 1;     /* Provide a layer */
    }
    
    .meContainerAlpha
    {
        position: absolute;
        top: -30px;     /* Move it UP 30px */
        left: 0px;
        z-index: 2;     /* Place it on top of the other layer */
        display: none;  /* Hide it */
        background-color: rgba(150,150,150,0.5);   
    }
    
    .meContainerAlpha:hover
    {
        display: inline; /* Show it */
    }
    

    Then you’d need to place these in divs inside your <li>.

    <ul>
      <li class="me">
        <div class="meContainer">
            <div class="meContainerLink">
                <img="dummy.png">
            </div>
            <div class="meContainerAlpha">
                &nbsp;
            </div>
        </div>
      </li>
      <li class="me">
        <div class="meContainer">
            <div class="meContainerLink">
                <img="dummy.png">
            </div>
            <div class="meContainerAlpha">
                &nbsp;
            </div>
        </div>
      </li>
    </ul>
    

    I don’t recall ever trying this method inside embedded <li> tags, so it may behave oddly at first. You may have to abandon <li> and switch to a different <div> structure entirely.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a navigation bar that when hovering over an item, the background image
I have a UIBarButtonItem on a navigation bar. I'd like to make it arrow
For the navigation controller I have onscreen, I'd like to place two images within
I have made a list based navigation bar for my newest project and I
I'd like to have an image to far left on my Navigation Bar, but
I'm designing a navigation bar. The code looks like this: <nav class=menu> <ul class=topnav>
I have a navigation bar which consists of a <img> elements within their respective
I have a navigation bar with some items like below screenshot. I need to
I have a navigation bar that has two dropdowns (as nested ul's). I'm trying
If have a Navigation Bar and a Tab Bar in one of my views.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.