CSS hover effects are malfunctioning

Having an issue with hover in CSS. Attempting to create a menu bar using saved PNG files, each file within its own div. When applying a class name and hover modifier, it only works on the first element. As the pointer moves to subsequent elements, they are all highlighted simultaneously. How can I resolve this problem?

Appreciate any help provided.

Code snippet:

<!DOCTYPE html>
<html>

<head>
  <meta http-equiv='Content Type' content="text/html ; charset=UTF-8">
  <title>Awantura Sluzewiec</title>
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0     /jquery.min.js"></script>
  <script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4 /jquery-ui.min.js"></script>
  <script type="text/javascript"></script>
  <style type="text/css">
    body {
      background: black url('images/background.png') top left no-repeat;
      background-size: cover;
    }
    header {
      background: url('images/logo_tittle.png') top left no-repeat;
      position: relative;
      top: 25px;
      left: 25px;
      width: 1215px;
      height: 157px;
    }
    nav {
      position: absolute;
      top: 50%;
      margin-top: -180px;
      left: 73px;
      width: 1073px;
      height: 40px;
    }
    .navButtons {
      display: block;
      left: 145px;
      position: relative;
      width: 149px;
      height: 40px;
      background-size: cover;
    }
    .navButtons:hover {
      box-shadow: 0 0 10px white;
    }
    #O_nas {
      background: transparent url('images/o_nas.png') center center no-repeat;
    }
    #Druzyna {
      background: transparent url('images/druzyna.png') center center no-repeat;
    }
    #Treningi {
      background: transparent url('images/treningi.png') center center no-repeat;
    }
    #Obiekt {
      background: transparent url('images/obiekt.png')center center no-repeat;
    }
    #Wyniki {
      background: transparent url('images/wyniki.png') center center no-repeat;
    }
    #Trener {
      background: transparent url('images/trener.png') center center no-repeat;
    }
    #Promil {
      background: transparent url('images/promil.png') center center no-repeat;
    }
  </style>
</head>

<body>
  <header></header>
  <div></div>
  <nav>
    <div id="O_nas" class="navButtons" </div>
      <div id="Druzyna" class="navButtons" </div>
        <div id="Treningi" class="navButtons" </div>
          <div id="Obiekt" class="navButtons" </div>
            <div id="Wyniki" class="navButtons" </div>
              <div id="Trener" class="navButtons" </div>
                <div id="Promil" class="navButtons" </div>
  </nav>

</body>

</html>

Answer №1

The issue lies in closing the tabs, which can be resolved by following this link: https://jsbin.com/tehusiqiye/edit?html,output

When seeking help from Stackoverflow for HTML-related queries, it is advisable to utilize the W3 HTML Validator prior, ensuring syntactical correctness of your HTML. This tool would have quickly identified the problem, saving valuable time and allowing experts here to focus on more significant inquiries.

Answer №2

If I understand correctly, you want to add a box shadow of 1px when hovering over an element with the 'navButtons' class. The issue is that every div in your HTML document has the same class. Instead of adding extra classes to each div, you can achieve this effect by simply copying and pasting the following code:

#O_nas {
      background: transparent url('images/o_nas.png') center center no-repeat;
    }
#O_nas:hover {
      box-shadow: 0px 0px 1px #fff;
    }

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

Increase the identification of HTML element with jQuery

I've encountered an issue while trying to increment the id of 2 HTML elements, hwAddition and itemNumber, upon a button click event. The HTML code in question is as follows: <div id="hwAddition"> <div id="itemNumber" s ...

Fixing Email Validation Error in AngularLearn how to troubleshoot and resolve

I'm encountering an issue when trying to develop an email center using regex pattern, as I'm receiving a validator error in HTML. I have already installed ngx-chips and angular-editor, imported all the necessary modules and dependencies. Here is ...

Find and conceal the object within the list that includes the term "Ice"

The teacher's assignment is to create a radio button filter that hides items with the word "Ice" in them, such as "Ice Cream" and "Iced Tea." Here is the current code I have been working on: <!DOCTYPE html> <html> <head> <me ...

Ways to Retrieve JavaScript Variable inside HTML Tags in a JSP

I am currently facing a requirement where I must assign js variables to html input tag ids. For example: <input type='text' id='(here I need js variable)'/> I am aware that one way to achieve this is by creating the entire elem ...

How to align a div in the center of a cell with Bootstrap

I am currently working with Bootstrap 3 and I have a specific requirement to center a div within a cell in the container row. Most resources I found only mention how to center a div within the entire container, which is not what I am looking for. My goal i ...

How can I locate specific images within a CSS sprite?

Are you searching for the correct process to pinpoint specific image locations within an image sprite? If, for example, you aim to create 10 div images in your header using the image provided below, how can you determine the exact location of each one? Is ...

Welcome to the interactive homepage featuring multitouch authentication

I am looking to design a homepage that is interactive based on touch input. For instance, if the user uses 5 fingers to touch the screen, similar to the green circles in the image below, they will be redirected to a specific homepage. If they touch in a di ...

When using jQuery, the content loaded with the $ajax function only displays after refreshing the page

Located on an external server is a directory containing various .html files, including one named index.html. The server has the ability to load either the folder name or foldername/index.html in its URL. Each html file within the directory loads a corresp ...

Guide to configuring capybara-webkit for testing ajax requests and capturing screenshots containing HTML with loaded CSS and JavaScript

Having some trouble setting up capybara-webkit on my Rails 4.2.1 app. Tests are running fine, links are being clicked, and ajax calls are working, but there's one odd issue with capybara-screenshot gem. I wanted to capture html screenshots with all as ...

Please select the links located beneath the see-through triangular or polygonal shapes

Review the code snippet provided at the following link: http://jsfiddle.net/q8Ycz <div style="background-color: red; width: 200px;" onclick="alert('behind')"> <div><a href="test">test test test test test test test test test ...

The issue with dynamic sizing in React and Tailwind is that it does not consistently work with arbitrary sizes. Some sizes do not appear properly, causing items to

In this code snippet, I am attempting to create a circle component of dynamically sized using html div and Tailwind CSS w-[diameter] & h-[diameter] attributes in a create-next-app@latest project. However, the circle fails to render properly with certa ...

Having trouble directing input to embedded swf upon page load in Opera

I have created a basic HTML file designed to display embedded flash content immediately upon loading, without requiring any prior interaction. Unfortunately, I have encountered an issue in my preferred browser, Opera. The problem seems to be isolated to th ...

Show or hide a div based on the visibility of another div in Angular using *ngIf

Looking for a way to dynamically display images based on the visibility of another image? Consider the code snippet below: <div *ngFor="let badge of user.progress.unlockedBadges"> <img id="{{i}}_unlockedImage" *ngIf="badge == achievemen ...

How can an HTML5 application be configured to enable access to intranet and local files?

It's a known fact that accessing the local path of a file added using a file input field or drag-and-drop is not possible even with the new FileAPI. Whether this limitation is good, bad, or ugly is not up for debate. The FileAPI specs clearly state th ...

Webstorm encounters difficulties compiling Sass

While attempting to utilize Sass in the Webstorm IDE, I noticed that it is defaulting to Ruby 1.8 (OS Default) instead of my preferred RVM Ruby Version (1.9.x). To address this issue, I tried setting the path for Sass in the Watcher-Configuration: PATH=$ ...

Looking to center the numbers in my ordered list within a border box - any tips on how to achieve this?

I'm attempting to create a numbered order list with a circular border around it. The goal is to have the number of the list item centered within the circular border and the entire circle centered within the paragraph. Currently, both the number and th ...

What is causing the divs to not stretch across the entire width of the parent div?

Interactive Code Example: Snippet: <div style="width: 100%; overflow: hidden; height: 65px; background: #00CC00;"> <div style="width: 60%; overflow: hidden; float: left; background: #3074A3; color: #EDEDED; height: 65px; text-align: center; ...

Issue with image preview functionality in dialog modal when loading content via ajax request

<table id="result"> <a href='#' class='pop'><span class='fa fa-eye'><img src='image link here' style='display:none'></a> </table> The hyperlink above is designed to open ...

Navigating within fixed-positioned divs

I'm attempting to create something similar to the layout seen on: The desired effect is to have fixed content on the right side, with only the left side scrolling up to a certain point before the entire page scrolls normally. However, in my implement ...

Navigating Through Secondary Navigation with Ease

In my React project, I am developing a mega-menu styled dropdown navigation. As a functional component, I am utilizing the useState hook to manage the state and control the display of sub-navigation items. The functionality of the dropdown is operational, ...