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

Detecting Specific Web Browsers on My Website: What's the Best Approach?

My website is experiencing compatibility issues with certain browsers, such as Firefox. I want to display a message when users visit the webpage using an unsupported browser, similar to how http://species-in-pieces.com shows a notification saying "Works ...

What is the best way to navigate to a specific ID on the homepage using a navigation button on another page?

When a navigation button is clicked on any page other than the home page, I want the home page to load first and then scroll to the corresponding id mentioned in the navlink. Below is the code snippet: <Col sm={5}> <Nav className=& ...

Tips for positioning a background image behind page content

I have a webpage with a background image, and now I want to add content that floats over it. However, the code below is placing the content behind the image. How can this be corrected? It's important to note that I'm attempting to achieve the ef ...

What is the correct way to adjust the style.top attribute of an element using JavaScript?

In order to correct a JavaScript source code, I need to adjust the style.top property of a div element based on an integer parameter from a function called index. Here is the current implementation: div.style.top = (index * 22 + 2)+"px"; However, for lar ...

Master the Art of Scrollbar Control in Angular!

I am currently developing a chat web application that functions similar to gchat. One of the key features I'm trying to implement is an alert notification when the scrollbar is in the middle of the div, indicating a new message. If the scrollbar is at ...

Tips for sending an email without using MAILTO in JavaScript or jQuery

Today is a great day for many, but unfortunately not for me. I've been struggling with this issue for over two weeks now and can't seem to find a solution anywhere on the internet. Stack Overflow always comes to my rescue when things get really t ...

Arrange the selection options by price using jQuery

Sorting options by price is my goal, but despite trying various codes, I have not been successful! This is the original structure: <select id="product-list"> <option>product 1- [2$]</option> <option>product 2- [4$]< ...

Resolve the issue of Dojo images not appearing on a div in Internet Explorer

I am trying to incorporate images into a dojo chart using the given code: var l_images = ["images/clearnight.png","images/clear.png","images/partlyCloudy.png","images/cloudy.png","images/showers.png","images/rain.png","images/thunderstorms.png","images/ic ...

What is the best way to create a clickable button link using PHP echo?

Whenever I click the button, it always redirects to just story.php, ignoring all other details. I attempted using JavaScript but I found that utilizing form action is the closest method for me to accomplish this: <form action='./story.php?u=$id&a ...

Access an HTML element and using JavaScript to make changes to it

As a new web developer, I am eager to create a grid of file upload zones on my site. I have decided to use DropZone.js for this project. I have customized DropZone and added multiple drop zones in the HTML. The grid layout consists of four rows with four ...

Having trouble making alerts or confirmation dialogs function in JavaScript

EDIT: Many thanks to everyone who helped fix this issue (: Your help is greatly appreciated! I've been struggling to get the alert, confirm, or prompt functions to work properly in my code. Here's a snippet of the code that's causing troubl ...

How to output a string in jQuery if it includes a certain character?

I need to extract all strings that include a specific word within them, like this: <div> <div> <span> <h3>In Paris (Mark Bartels) worked for about 50 years.</h3> </span> </div> ...

"Trouble with image height not scaling correctly in Internet Explorer when using the img tag

I am facing an issue that can be observed by visiting this link using Internet Explorer. Interestingly, everything functions perfectly in all other browsers (although Chrome displays little blue squares next to the images for some unknown reason). Here i ...

Arranging XML information in PHP from most recent to oldest

I have a working code that I want to modify so that the Observed Data is displayed from the newest date to the oldest. How can I flip only the Observed Data? Here is my current code: <?php $url = "http://r7j8v4x4.map2.ssl.hwcdn.net/NOD_R.xml"; $xml = ...

Transfer information from a server to a client using the fetch API in pure JavaScript

Hey there, I've been working on a mini app that sends a fetch request to the backend and expects some information in return when a button is clicked. However, I'm facing an issue where the fetch call seems successful with a 200 status, but the d ...

Adding one class at a time, with each new class being added every second

My goal is to add classes one by one [test0 test1 test2] up to 10, with each class being added after one second. $('.rating-block').AddClass('test0 test1 test2 ... test10' ); I am experimenting with the following code, but I don' ...

The click event will not be triggered if the element is removed by my blur event

My dropdown list is dynamic, with clickable items that trigger actions when clicked. Upon focus, the list displays suggested items When blurred, the list clears its contents The issue arises when blur/focusout events are triggered, causing my element to ...

"Customize your map pins on Google Maps by updating the marker location through a

I am trying to update the position of a map marker based on a dropdown selection. Upon changing the dropdown option, I retrieve the latitude and longitude values and want to set these coordinates for my current marker. Here is the code snippet: $("#locati ...

Extract information from page 1 to page 2 by utilizing ajax

Greetings, I am currently facing an issue with parsing data using the href get method to retrieve PHP by ajax on another page. Is this achievable? By the way, my framework of choice is CODEIGNITER. This is my HTML href code snippet: <a href="'.b ...

Trying to display logo using 'content' property in CSS

I've been trying to display a logo on the header of my website, but I'm having trouble getting it to show up. I attempted to set the logo using HTML syntax as well as the following CSS code: .div { content: url (...jpg); } However, both metho ...