Background image fades on Firefox as it moves

Implementing a method detailed here to achieve a fading effect on a background image when hovering over an element.

Check out my example on CodePen: http://codepen.io/anon/pen/vqtjf

HTML:

<div><span></span></div>

CSS:

div {
    position: relative;
    width: 219px;
    height: 218px;
    background: url(https://dl.dropboxusercontent.com/u/3454522/home-option-icon-off.png) no-repeat;
}

span {
    position: absolute;
    top: 0; left: 0; bottom: 0; right: 0;
    background: url(https://dl.dropboxusercontent.com/u/3454522/home-option-icon-energy.png) no-repeat;
    opacity: 0;
    -webkit-transition: opacity 0.5s;
    -moz-transition:    opacity 0.5s;
    -o-transition:      opacity 0.5s;
}

div:hover span {
    opacity: 1;
}

In Firefox (Mac), I encounter a challenge where the background image of the span is misaligned with the parent background, causing a slight movement during the fade-in effect (vertically in the codepen example, but potentially horizontally in a more complex project setup). Resizing the browser window seems to temporarily resolve this issue.

Watch a screencast demonstrating the problem here: (View at 100% for a clear view of the subtle issue).

Any insights into what might be causing this discrepancy or suggestions for fixing it?

Answer №1

It seems like there is a discrepancy in how Firefox handles images with opacity animation, especially when they have been resized using HTML width/height attributes (often by more than 50%). The issue can manifest as a subtle offset (~1 px) or some form of antialiasing.

Steps to Reproduce:
1. Open the provided testcase
2. Hover the mouse over the images to trigger the opacity animation
3. Experiment with different zoom levels to observe the offsetting/antialiasing

One workaround is to add "box-shadow: #000 0em 0em 0em;" to the images to correct the rendering issue.

Source: https://bugzilla.mozilla.org/show_bug.cgi?id=745549

Answer №2

Encountered a similar issue and managed to resolve it by including the following code in the image's CSS:

transform: translate3d(0,0,0);

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 effectively handling color inheritance within Bootstrap 5

I need to customize Bootstrap 5 .text-success color for better contrast on my custom .bg-lvlN classes. Here is how I have defined them: .bg-lvl1 { background-color: #303333; } .bg-lvl2 { background-color: #222424; } /* Overriding .text-success c ...

When looking for a selection, the drop-down list unexpectedly shifts upwards

When using the ngx-intl-tel-input library in my Angular application, I noticed that when searching for a country in the dropdown list, it moves to the top. I am looking to fix the position of the dropdown menu while searching. Check out the demo: Demo Lin ...

Unable to utilize multiple instances of bootstrap modals within a Django template

Currently, I am working on a template view where I need to open multiple modals one at a time. The structure of this template includes tabs with trigger buttons for the modals placed between the tab navigations and content. Previously, I have successfully ...

Is your browser tab failing to display the complete URL?

Encountering a strange issue while working on my current website project: When you click on "about," it does take you to the correct page, but upon refreshing the page, it redirects back to the home page. The same scenario is happening with other pages as ...

What is the method to display the bootstrap carousel controls on top of the images rather than beside them?

As a beginner, I'm utilizing the carousel code provided by Bootstrap. While it's functioning, the controls are taking up space to the right and left of the image instead of overlaying them. In an attempt to resolve this issue, I added the follow ...

Adjust the height of the image using CSS while maintaining its aspect ratio within the Gall-Peters projection

I've implemented a Gall-Peters projection on my website and I'm looking for the right CSS code to maintain its aspect ratio. I want the image to take up 100% of the available width without elongating the countries' shapes. Can anyone help wi ...

Achieving CSS centering with translate and avoiding content overflow

I have a code snippet for centering content both horizontally and vertically. It functions properly unless there is too much content, in which case it gets cut off. Is there a CSS solution to prevent this overflow issue without involving JavaScript? .b ...

The slider feature is not set to automatically slide on its own

I need help creating a JavaScript slider that includes next and previous buttons. The functionality for these buttons is working properly, but I also want the slides to transition automatically. <link rel="stylesheet" href="http://www.w3schools.com/l ...

The Carousel feature in Bootstrap 4 is malfunctioning on the website

I've inserted a carousel into my webpage but it's not functioning as intended. I'm attempting to use this carousel code from "codepen.io/decibeldesign/details/bMrQKN" and the full webpage code can be found at "paste.ofcode.org/saJPkuhPPixFmX ...

"ExceptionThrownByMoveTargetOutOfBounds in Selenium WebDriver for IE9 and Firefox

Having trouble with the FireFox/IE9 driver in Selenium? When using the Actions class and its moveToElement method, I keep encountering a MoveTargetOutOfBoundsException error. Despite trying different solutions like Coordinates, Point, and javascriptexecuto ...

The onclick function only triggers after the second click

I have an issue with my image view onclick function code. Currently, the code works perfectly but only when I click for the second time. I am not sure what the problem is and would appreciate any help in fixing it. Below is the code snippet: <script ...

Is there a way to transform text input into a dropdown menu that dynamically alters the rows of a table?

Currently, I am working on creating a drop-down menu selection that will dynamically change the table rows based on user input. At the moment, users can enter their input into a text field to see changes in the table rows. However, I would like to impleme ...

Leveraging the "dialogclose" event within jQuery Mobile

Is there a way to change an image once it is clicked and change back when the dialog it links to is closed? I found a potential solution on this site, but after modifying it for my needs, it doesn't seem to work. Can anyone help me figure out what I a ...

What is the best way to conceal elements that do not have any subsequent elements with a specific class?

Here is the HTML code I have, and I am looking to use jQuery to hide all lsHeader elements that do not have any subsequent elements with the class 'contact'. <div id="B" class="lsHeader">B</div> <div id="contact_1" class="contac ...

Utilizing Jquery on the client side in conjunction with a Node.js server

I am using nodejs within a docker-compose container to create a local web app. My goal is to use jquery on the client-side to load an HTML file into a div, but I'm encountering issues with it not working properly. Both the initial index.html and the n ...

Collaborative Artistry: Using HTML5, JavaScript, and Node.js for Multiplayer

Creating a multiplayer drawing application for touch-enabled devices has been a challenge. I have utilized Node.js with Socket.io to draw points on a canvas, but there's an issue with the touchend event not resetting properly. To illustrate, take a l ...

The colgroup tag is present in the code, but strangely absent from the view source or debugger tool

In a curious twist from this question Why does Firebug add <tbody> to <table>?, I have encountered a similar issue that may lead to the same answer, but I am seeking confirmation. Within my code, there is a colgroup element that mysteriously d ...

Ensuring Contact Form Accuracy with Jquery Validation

I am trying to implement form validation using jQuery. Here is the code I am using: <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2 /jquery.min.js"></script> <script type="text/javascript" src=" http:// ...

Guide to redirecting on click when utilizing an iframe

I needed to prevent the page from reloading before the action was complete by using an iframe. However, I encountered an issue where I needed the page to refresh after the action took place. I attempted two methods to achieve this - refreshing the page and ...

Difficulty with Jquery's random selection of grid divs

I am working on a grid layout consisting of 9 divs nested in columns of three. The objective is that when the main grid (with ID #left) is clicked, two divs from the middle row (row="1") should have the class .show randomly applied to them. In the column w ...