Anomalous Hover Glitch in Internet Explorer 7

Here is a snippet of my custom CSS styling:

#languages_menu
{
  background: url('/images/langs.png') repeat-y;
  bottom: 40px;
  font-size: 0.9em;
  right: 10px;
  position: absolute;
  width: 90px;
}

#languages_menu ul, #languages_menu ul li
{
  list-style: none;
}

#languages_menu ul li a
{
  cursor: pointer;
  display: block;
  line-height: 22px;
  margin-left: 10px;
  text-decoration: none;
  width: 80px;
}

#languages_menu ul li a:hover
{
  background-color: #AEBDD2;
  color: #F00;
}

#languages_menu ul li a span.flag
{
  float: left;
  margin: 3px 5px 0 3px;
}

Below is the HTML code I used (taken from Developer Toolbar for accuracy):

<!-- DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd" -->
...
<DIV id=languages_menu><DIV class=topimg></DIV>
  <DIV>
    <UL>
      <LI><A class=en><SPAN class=flag></SPAN><SPAN class=name>English</SPAN></A></LI>
      <LI><A class=fr><SPAN class=flag></SPAN><SPAN class=name>Français</SPAN></A></LI>
      ...
    </UL>
  </DIV>
</DIV>

:hover functionality in IE7 or earlier versions seems to be causing some trouble with the anchor elements not changing on mouse hover.

Interestingly, other similar code snippets on the same page are functioning as expected even in IE7, like this one:

#navigation
{
  height: 22px;
  position: relative;
  width: 100%;
}

#navigation ul
{
  float: left;
  left: 50%;
}

#navigation ul, #navigation ul li
{
  float: left;
  list-style: none;
  position: relative;
}

#navigation ul li
{
  right: 50%;
}

#navigation ul li a
{
  color: #889DBF;
  display: block;
  line-height: 22px;
  padding-left: 20px;
  text-decoration: none;
}

#navigation ul li a b
{
  display: block;
  padding-right: 21px;
}

#navigation ul li.current a, #navigation ul li a:hover
{
  background: url('/images/navigation-left.png') no-repeat;
  color: #111B35;
}

#navigation ul li.current a b, #navigation ul li a:hover b
{
  background: url('/images/navigation-right.png') no-repeat 100% 0;
  color: #111B35;
}

<DIV id=navigation>
  <UL>
    <LI class=current><A href="#login"><B id=text_menu_login>Accedi</B></A></LI>
    <LI><A href="#register"><B id=text_menu_register>Registrati</B></A></LI>
    ...
  </UL>
</DIV>

If anyone has insight into why this issue is occurring and how it can be resolved, please share!

[EDIT] A workaround solution has been discovered: Replacing:

#languages_menu ul li a:hover

With:

#languages_menu ul li:hover a

This adjustment allows the menu to function correctly even in older versions of IE. However, using the :hover pseudo-class may not assure perfect cross-browser compatibility as it's not supported in IE versions below 7.

Thanks a lot, Eric, for your help!

Answer №1

Make sure to include a href attribute in your anchor tag for it to be recognized by IE7 when hovered:

<A class=en href="#">

Another tip is to insert an empty rule in your CSS file:

#languages_menu ul li a:hover {
  /* Add all your hover effects here */
}

#languages_menu ul li:hover a {
  /* Leave this empty to activate a:hover on IE7 */
}

Answer №2

Set the default background color for your regular link to white.

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

Tips for creating an array:

Currently, I am working on a project that involves using an array of objects. While I have a good understanding of what an array is and how to create an object, I am struggling with incorporating my student object into the array. In this project, each st ...

PHP include does not bring in the CSS file

My project has a main.css file stored in the styles folder at the root: #header { background-color: aqua; height: 120px; } Within header.php, there is the following code: <!DOCTYPE html> <html> <head> <link rel="styleshe ...

Using Java Selenium to navigate a webpage using XPath

I am attempting to use selenium for the purpose of logging in, navigating, filling out a form and downloading a file. When I try to navigate by clicking on a link, it seems pretty straightforward. However, since the link does not have an ID or name attribu ...

"Embedding a Highcharts web chart within a pop-up modal window

I am looking to incorporate a Highcharts web chart onto a specific part of a Bootstrap modal, while ensuring the size remains dynamic along with the modal itself. Here's what I have attempted so far: Sample HTML code: <td><a href="#">${ ...

What causes the width of unrelated cells to change when the contents of colspan'd cells expand in IE7?

Before we delve into the details, I invite you to take a look at this fiddle using IE7. It's quite intricate and not something I want to repeat here. The main issue is that clicking on the red block should display additional information. The top row ...

Using Angular JS to retrieve specific information from a JSON file

I am in the process of developing an AngularJS app that showcases notes. The notes are stored in a note.json file, and the main page of the app only displays a few fields for each note. I want to implement a feature where clicking on a specific note opens ...

Accessing a distinct element of e.parameter

I've implemented a Google App Script on my website that automatically writes form data to a spreadsheet upon submission. With multiple forms on the site, I want all their data to go to the same Spreadsheet but different 'Sheets' (tabs at th ...

Creating a dynamic visual effect by changing the background color's opacity with each

Is there a CSS or Less solution to change the background color of all dynamically added or removed child elements with a gradual increase of opacity? ul li { list-style: none; font-size: 16px; text-align: center; font-weight: bold; margin: 3p ...

Conceal the dormant brothers and sisters within the nested list

My tool relies solely on JavaScript for functionality. I have created a nested list structure using JSON data: function buildList(data, isSub){ var html = (isSub)?'<div class="nested">':''; // Wrap with div if true ht ...

Using React to inject SCSS classes on the fly

Looking for advice on the best way to dynamically insert SASS classes using React. I have a React component that takes in two props: componentId and color. These components are displayed as a list, and each time they're rendered, I want to apply the ...

Transitioning Between Div Elements Using Jquery

I am stuck with the following HTML code: <section> <div id="first"> ---content </div> <div id="second"> ---content </div> </section> When the page loads, the second div and its contents are not visible (I'm uns ...

implementing HtmlSpanner with an appended css stylesheet

Using HtmlSpanner with CSS for TextView I recently discovered a library called HtmlSpanner that claims to assist in adding an HTML string with CSS to a TextView. However, I am struggling to locate any detailed documentation on how to achieve this, except ...

Looking for a skilled JavaScript expert to help create a script that will automatically redirect the page if the anchor is changed. Any t

Seeking a Javascript expert, In my custom templates, I have used a link as shown below: <a href='http://www.allbloggertricks.com'>Blogging Tips</a> I would like the page to redirect to example.com if the anchor text is changed from ...

A dynamic, multi-column, two-dimensional layout using CSS Grid

Within my HTML structure, there exists a single container div followed by a variable number of child divs. The objective is to implement a multi-column layout for these child divs based on their respective class names. <div class="list-units"> & ...

Send variable to jQuery from a div element

I'm struggling with adjusting the height and width of a dialog box using a jquery function. I want to pass a parameter from within the DIV, but I haven't been successful in finding a solution. Any suggestions would be greatly appreciated. $.fx.s ...

arrangement of a list with the specified information stored in each item

Presently, my task involves setting up a dynamic gallery page with multiple tabbed lists that are fetched from the database. Each list corresponds to a specific Gallery Name and is associated with a unique data-list-id. Furthermore, each gallery contains ...

What are some strategies for customizing the appearance of child components within a parent component?

I have a scenario where I am using parent and child components. When I use the HTML in another component, I also apply my CSS. For example, in my parent component: HTML <div class="chips"> <p class="tags">Tag 1</p&g ...

Display scrollable content at the bottom

I am currently working on creating a chat application using JavaScript (AngularJS without jQuery) and I am wondering if it is possible to have a scrollable div load to the bottom automatically. While I am familiar with the scrollTo JS property, I do not f ...

Eliminate the spacing between elements when they are in close proximity

I've noticed there is a margin between the buttons as shown below: .button + .button { margin-left : 1rem; } The buttons are contained within a <div class="row">, which will stack on top of each other on smaller screens: https://i.s ...

The Verdana font in Microsoft Word appears with a distinct rendering when converted to an HTML-based

I'm currently working on generating a PDF from an HTML template. Our customer provided the template they previously used in Word, and they require the font to be Verdana. The challenge I'm facing is that Verdana looks smaller and has a different ...