Broken href link on background image with absolute positioning

Having trouble adding a link over a background image of the head-bg-image div into ul li. The link is not functioning properly.

<div id="product_banner">
<div class="head-bg">
<div class="head-bg-img"></div>

<ul class="d-inline-block " style="nav navbar navbar-left d-flex d-inline-flex" >
    <li class="nav-item d-inline-flex  align-items-center mr-2" style="margin- 
left:25px;color:#959c97;">
        <a>Home</a>
    </li> 
    <li class="nav-item d-inline-flex  align-items-center mr-2" style="margin-left:25px; 
    color:#959c97;">
        <h5>Service 2</h5>
    </li>
    </ul>

The CSS code is as follows, but even hover functionality is not working:

#product_banner .head-bg-img {
position: absolute;
left: 0;
top: 0;
background: url(http://demo.nrgthemes.com/projects/nrgnetwork/img/bg.jpg);
height: 100%;
width: 100%;
background-size: cover;
opacity: 0.2;
z-index: 1;
background-position: center center;
}

#product_banner .head-bg-content {
height: 400px;
text-align: center;
position: relative;
z-index: 200;
display: table-cell;
vertical-align: middle;
width: 5000px;
} 

Below is the code for hover effect, which is also not functional:

 product_banner .head-bg-img a{
 color:#fcfffd;
 font-weight:bold;
 }
 #product_banner .head-bg-img a:hover{
 color:#fcfffd;font-weight:bold;
 }

Answer №1

Successfully implemented solution: I resolved the issue by eliminating the "z-index: 1;" in ".head-bg-img" as it was causing the background to overlap the content, rendering the links non-functional. When writing the hover code, ensure to include "#" before "product_banner .head-bg-img a". Additionally, make sure to target the "a" within "nav-item" instead of "head-bg-img" since the links are child elements of the nav-item class. It is vital to verify the HTML hierarchy to accurately reference the CSS selectors.

#product_banner .head-bg-img {
position: absolute;
left: 0;
top: 0;
background: url(http://demo.nrgthemes.com/projects/nrgnetwork/img/bg.jpg);
height: 100%;
width: 100%;
background-size: cover;
opacity: 0.2;
background-position: center center;
}

#product_banner .head-bg-content {
height: 400px;
text-align: center;
position: relative;
display: table-cell;
vertical-align: middle;
width: 5000px;
}
 #product_banner .nav-item a{
 color:#959c97;
 font-weight:bold;
 }
 #product_banner .nav-item a:hover{
 color:#fcfffd;font-weight:bold;
 }
<div id="product_banner">
  <div class="head-bg">
  <div class="head-bg-img"></div>

  <ul class="d-inline-block head-bg-content" style="nav navbar navbar-left d-flex d-inline-flex" >
      <li class="nav-item d-inline-flex  align-items-center mr-2" style="margin- 
  left:25px;color:#959c97;">
          <a>Home</a>
      </li> 
      <li class="nav-item d-inline-flex  align-items-center mr-2" style="margin-left:25px; 
      color:#959c97;">
          <a>Service 2</a>
      </li>
   </ul>
 </div>

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

How can I create a popup window that meets standards using XHTML and Javascript?

As I adhere to writing standards compliant XHTML Strict 1.0, I refrain from using the HTML "target" attribute on anchor elements. I have come across 2 distinct methods involving Javascript: One approach involves locating all links with rel='exter ...

How can I combine an onkeypress and onclick event listener in one method?

I have two inquiries, somewhat intertwined. 1) Is it feasible to merge the 2 functions below into a more efficient function, or do I need to create a function and then call it in both event listeners? input.addEventListener("keyup", () => { if (eve ...

Dynamic content display using AJAX

Having already tried to find a solution through Google with no success, I am at a loss. I have articles where a paragraph is initially displayed, followed by a "read more" link which reveals more content using JavaScript. However, this approach may slow do ...

Place the division at the bottom of the screen

I'm facing an issue where I am trying to place a div at the bottom of the viewport but it's not working as expected. Here is how my current setup looks like: html <div class="parent"> <div class="bottom"> </div> </div&g ...

The image tag disrupting the spacing between lines

Here's a snippet of the css and html code: CSS: div { height:24px; line-height:24px; } HTML: <div><img src="image.png"/>Text</div> According to the code, a div should be 24 pixels high with text vertically centered after ...

Content in the Bootstrap carousel is not displaying properly within the arrow indicators

While working on my project and trying to implement a carousel element, I encountered an issue. The carousel arrows and autoplay options are functional, but the content does not appear between the arrows as expected. First, I included bootstrap in my proj ...

Developed a basic HTML form using PHP, however encountering issue where email is not being posted and instead opening a blank page

After creating HTML and PHP documents, I encountered an issue where upon submitting the form, I ended up with a blank page and didn't receive the expected email containing the form information. As someone relatively new to this, I would greatly apprec ...

Creating an image overlay within HTML text in NSAttributedString with CSS: A step-by-step guide

I am currently working on extracting HTML text that includes a YouTube video. In order to showcase this video, I have implemented a preview image. The original text is as follows: <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do ei ...

Show or hide comment sections using jQuery on a single webpage

Currently, I have implemented a script to toggle the visibility of comments on several WordPress-based websites. The script works well on most sites, but I am facing an issue with a site using the Hero theme. On the index pages, the theme displays content ...

Transform Vue.js into static HTML output

Is there a way to convert a Vue.js component into static html without the need for javascript? I am specifically interested in retaining styles. I am searching for a library where I can execute code similar to this: SomeNestedComponent.vue <template> ...

- bullet point: tabulated

I need to create an unordered list with URLs included and indented, while keeping all lines justified to the left. * line one text text ted more text text text * line two text ted more text text text * line three text ted more text text text ...

Has the default underline in Bootstrap 5 been altered?

When working with Bootstrap 4, I noticed that it sets the default text-decoration to be none. However, in Bootstrap 5, just adding a regular anchor tag results in both blue text and an underline being displayed. I was trying to achieve only showing the u ...

Including hyperlink tags within a CSS file

Can you create internal links within a CSS file, like inserting a table of contents at the top where you can click on an item and immediately jump to that section in the CSS file similar to an anchor tag? This feature would be extremely handy for long CSS ...

What occurs when multiple HTML tags are assigned the same string as their ID attribute value?

While browsing a html page, I stumbled upon several tags that I thought had the same id. It turns out they were unique, but it got me thinking - what would happen if multiple tags actually shared the same id? I've always heard that the id attribute o ...

Why is object-fit not functioning properly? Could it be that the container is influencing the object-fit

Why isn't object-fit working? It only seems to work with inline styling in the image tag. Could it be the hero_media container affecting object-fit? I'm also attempting to use pseudo-elements (after and before) to add text to the image. Is it nec ...

Issue with flash installation

I'm currently working on a WordPress website at www.studium.cl. However, I've encountered an issue when trying to open it in Internet Explorer. Each time I try to access the site, a window pops up prompting me to install Adobe Flash Player. Even ...

Error message: Unable to find child element in Selenium WebDriver

I'm currently dealing with a registration page where I encountered an issue. During my testing phase, I attempted to register without inputting a first name. Upon clicking the register button, I expected to see a 'Required' notification la ...

Update the CSS of a different element when hovering

Hello to all the jQuery developers out there! I have a question that's fairly simple. I'm trying to change a CSS attribute for an element when I hover over a different element on the page. I've created a fiddle for you to review, and I&apos ...

What is the best way to retrieve the parent element in jQuery when you already have the child element selected

I am working with jQuery Mobile, which automatically generates a lot of the DOM structure. The challenge I am facing is removing radio buttons without having an id for the parent div due to the HTML construction in jQuery Mobile. While I can easily targe ...

Issue encountered while trying to modify the color of a placeholder

Whenever I attempt to modify the placeholder's color: ::-webkit-input-placeholder { /* WebKit, Blink, Edge */ color: #909; } :-moz-placeholder { /* Mozilla Firefox 4 to 18 */ color: #909; opacity: 1; } : ...