(CSS/HTML) How to hover over an "li" element without affecting the text inside the "li" element

Looking for some assistance.

I've created an unordered list with list items and applied the following CSS to it:

li {
opacity: 0.5;
}

li:hover{
opacity: 1;
}

The issue arises when I hover over a pixel from within a word in "li" - it stops hovering and reverts the opacity back to 0.5, creating a flickering effect as I move the mouse around. How can I make the "li" behave like a block to prevent this from happening? I've attempted to nest a div inside each "li" and apply div:hover, but encountered the same problem. Appreciate any guidance.

FULL HTML AND CSS (excluding margin and reset css):

<!DOCTYPE html>
<html>
  <head>
      <title>Example</title>
      <link rel="stylesheet" href="file.css">
      <link rel="stylesheet" href="reset.css">
  </head>
  <body>
    <div class="header">
      <p><span>Example </span>One</p>
      <ul id="nav_bar">
        <li class="nav_button"><a>Overview</a></li>
        <li class="nav_button"><a>About</a></li>
        <li class="nav_button"><a>Help</a></li>
      </ul>
      <p id="intro">Random message here.</p>
      <div id="PlayNow">Click here to x!</div>
      <p id="versao">For bla bla<p>
    </div>
  </body>
</html>

font-face {
  font-family: UbuntuR;
  src: url(Ubuntu-R.ttf);
}

@font-face {
  font-family: UbuntuB;
  src: url(Ubuntu-B.ttf);
}

@font-face {
  font-family: UbuntuL;
  src: url(Ubuntu-L.ttf);
}

body{
  background-color: #e4a714;
  cursor: default;
}

.header {
  padding: 16px;
  position: relative;
  text-align: center;
  background-color: #231f20;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  -khtml-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

.header span{
  font-family: UbuntuB;
}

#nav_bar .nav_button {
  display:inline-block;
  padding-left: 6px;
  padding-right: 6px;
  cursor: pointer;
  opacity: 0.5;
  font-family: UbuntuL;
  color: white;
  font-size: 16px;
}

#nav_bar .nav_button:hover{
  opacity: 1;
}

.header p{
  color: white;
  font-family: UbuntuL;
  font-size: 26px;
  padding-bottom: 12px;
}

#intro {
  padding-top: 25px;
  padding-bottom: 30px;
  font-size: 38px;
  font-family: "Segoe WP", "Segoe UI Light", "Segoe UI", "Helvetica Neue", "Arial", sans-serif;
}

#PlayNow {
  background-color: #e4a714;
  font-family: UbuntuL;
  display: inline-block;
  color: white;
  padding: 15px;
  font-size: 24px;
  border-radius: 3px;
}

#PlayNow:hover {
  background-color: #ffbb16;
}

#versao {
  font-family: font-family: "Segoe WP", "Segoe UI Light", "Segoe UI", "Helvetica Neue", "Arial", sans-serif;
  margin-top: 6px;
  font-size: 16px;
  opacity: 0.6;
}

After removing:

<div class "logo"><img class="logo" src="http://i.imgur.com/jufQbVj.png"></div>

from the code, it started functioning correctly.

Any tips on where I might be going wrong would be much appreciated. Thank you.

Answer №1

To eliminate the issue, make sure to adjust margin-top to -50. The inconsistent image margin is overlapping the unordered list, resulting in the fade in-out effect.

If you want the logo to be nearer to the menu, consider using a photo editor for necessary adjustments.

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

An unusual 1px variance appears in the background-image on Internet Explorer

Having trouble with a sprite of two images showing a 1px difference in ALL versions of Internet Explorer, yet working perfectly in Firefox. Check out the demonstration here: http://jsfiddle.net/bHUs3/6/ I'm feeling frustrated. What could be causing ...

What could be the reason for an element with a width of 100% not recognizing the width of its parent?

One issue I'm currently experiencing is my inability to match the width of the parent within a flexbox item. Below is the code snippet, where the span element does not have the same width as its parent. .container { display: flex; } .item1 { ...

Are JQuery functions affected when navigating between pages in smart-tables?

Apologies if this question has been answered before or seems obvious. I couldn't find a solution after searching, and as someone new to web development, I might be going in circles here. Issue: I've integrated the smart-table extension () into ...

Having issues with the Carousel feature in Bootstrap 5.3.1 while using Angular version 15

I'm currently in the process of setting up a carousel on my homepage. It seems like everything is in place, but there's something missing. The initial image, text, and arrows all display properly, but they are non-functional. I have correctly imp ...

What is the best way to align a submit button and select option in a row within a form using Bootstrap?

I'm having trouble aligning a submit button to the right within a Bootstrap form. I've experimented with float-right, text-right, and align="right", but none of them seem to be working. Below is the code snippet: <!DOCTYPE html& ...

Footer overflows content

My footer is getting overlapped by the slideshow on my webpage. I have already attempted to clear the previous DIV in the source code as per the usual recommendation: <div class="clear"></div><!-- /clear any floats --> However, this sol ...

Python Ordering menu items for the Pelican restaurant

In response to jcollado's advice on this thread, I have set up my menu as per his instructions. However, I am facing difficulty adding the active CSS to the active item. DISPLAY_PAGES_ON_MENU = False DISPLAY_CATEGORIES_ON_MENU = False MENUITEMS = ( ( ...

Navigating from an offspring link to a social media platform page

I just launched my website and noticed that some sites and ads redirect users to their social media pages directly from the site. For example: mysite.com/facebook redirects to facebook.com/mysitesfbpage mysite.com/twitter redirects to twitter.com/mysite ...

What is the proper way to utilize li.class:hover in CSS code?

When trying to apply a class to an li element during a hover event, I encountered some difficulties. Below is the code that works without the class: #leaderboard li:hover { z-index:1000; -webkit-transform: scale(3.2); -moz-transform: scale(3.2 ...

Issue with submitting form using Jquery on select action

There seems to be an issue with this jquery code that is supposed to trigger a form submit when a drop down select is changed. It works fine on our test site, but once we move it to the live website, it breaks. Can someone help us troubleshoot and identify ...

Recalling the position of the uploaded image within a v-for loop

I am struggling to solve this issue. Currently, I am utilizing Vue.js in an attempt to construct a dashboard where users can upload up to five images of visitors who are authorized to access a specific service provided by the user. Below is the code snip ...

What is the method to obtain the content height of individual pages in Android, with or without the use of JavaScript?

I am facing an issue while trying to retrieve the content height of each webpage consecutively. When I load pages separately, I can successfully get the height of each page. However, when I attempt to fetch the content height continuously for webpages in a ...

Listen for the chosen choice

What is the best way to display a chosen option in PHP? I have set up an HTML menu list with options for "Buy" and "Sell". I need to output 'I want to buy the book' if someone selects "buy", or 'I want to sell the book' if someone pick ...

Change the text inside a container without losing any associated event listeners using JavaScript or jQuery

Here is the HTML code: <div id="div001"> This is ${Row.1}. <p>${Row.2} explain something else.</p> <p>${Row.3} welcome you. <span>${Hello.World}, this is a new world.</span></p> </div> My objective is ...

Enhancing Website Visibility: Utilizing PHP and JQuery to Update Page Content for Viewers

Imagine having a social networking platform where users can post updates and see them appear in real-time on their timeline. The challenge arises when these updates are only visible to the user currently logged in on a specific device. How can we utilize j ...

Ensure that all `thead th` elements remain in a fixed/sticky position when using a data

I am facing an issue with my data table requirement. I need to have 2 thead elements in the table, both of which should stick when scrolling. However, only the last thead's tr stays stuck at the top while the first one gets hidden. Can anyone help me ...

Solutions for concealing the current div when clicking on a new div that reveals a fresh one

Is there a way to hide the current div once you click on a new div that reveals another one? The code below toggles the display of the div, but what I am attempting to achieve is that when you click on a new item after clicking on the first one, the first ...

Discover the best way to implement aliases for embedded base 64 images within HTML code

I am trying to incorporate Base64 embedded images into my HTML file, but the image sizes are over 200k, making the base64 data part very large. To address this issue, I would like to place these images in another tag, such as a script, and attach them at ...

Uploading API documentation from .chm files

Currently in the process of documenting our extensive code base using Sandcastle to generate .chm files with inserted XML comments. My next step is hosting these files on our server as a website for easy access rather than distributing documentation indi ...

Are there any SVG libraries available that can create line graphs similar to those seen in Google Analytics?

The line graph in Google Analytics that is created using SVG is quite impressive. Are there any libraries available that can generate similar line graphs to those in Google Analytics? ...