When hovering, CSS background image hyperlinks shift slightly

I'm facing a slight issue with my CSS hover images, particularly in Safari and Chrome. When hovered over, the images jump or get squeezed, sometimes even disappearing when resizing the browser window.

Although it's barely noticeable (about 1px wide), the problem persists. I initially thought it was due to the responsive nature of the website and the downsizing of the images.

However, Firefox handled it smoothly without any strange jumps on hover (apart from some aliasing).

I appreciate any assistance you can provide regarding this matter.

Here is a snippet of the code showcasing the issue:

Answer №1

Your approach to preloading content is strong, but consider removing the double slashes from the URLs in the :hover declarations.

For instance, browsers like Chrome may treat these two URLs as separate images:

https://couill.art/wp-content/uploads/2018/06/Danger-Zone-Logo-website-thumbnail.gif

https://couill.art//wp-content/uploads/2018/06/Danger-Zone-Logo-website-thumbnail.gif

Note: While this fix resolves flickering on Chrome, it may introduce issues on Firefox. One solution is to avoid targeting a elements with :hover, as the img tag already covers their background. Simply use:

.project-panel .pp-thumb a[title="Danger Zone"] {
    background: url(https://couill.art/wp-content/uploads/2018/06/Danger-Zone-Logo-website-thumbnail.gif) no-repeat;
    background-size: contain;
}

By setting the visibility of the img to hidden on hover, you can display the animation smoothly without any flickering.

Below is the corrected CSS code snippet that should work effectively:

.project-panel .pp-thumb a[title="Danger Zone"] {
    background: url(https://couill.art/wp-content/uploads/2018/06/Danger-Zone-Logo-website-thumbnail.gif) no-repeat;
    background-size: contain;
}
.project-panel .pp-thumb a[title="Dangerz"] {
    background: url(https://couill.art/wp-content/uploads/2018/05/Thicc-girls-slim-boi.gif) no-repeat;
    background-size: contain;
}
.project-panel .pp-thumb a[title="Danger II"] {
    background: url(https://couill.art/wp-content/uploads/2018/05/trio-trompettes-rouge-1.gif) no-repeat;
    background-size: contain;
}
.project-panel .pp-thumb a[title="About"] {
    background: url(https://couill.art/wp-content/uploads/2018/05/chauve-souris-anim.gif) no-repeat;
    background-size: contain;
}

You can view a live example here.

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

How to Align Printed Output in Angular Components

I am a beginner in Angular and I am looking to display modal information. To print the data, I am using onclick=print(). The data shows up in the print preview, but it is not aligned correctly. Here is a screenshot of my page. I want to align the data prop ...

Issue with sticky navigation bar causing page content to shift

Any ideas on how to solve my issue with a sticky nav bar in Twitter Bootstrap? Whenever I scroll past a certain point, the navbar sticks but causes my content to jump. I want the content to stay in place without jumping. Here is my HTML code: <body> ...

How can I transfer CSS styles from one class to another using JQuery?

Is it possible for me to create a timepicker that matches the style of the datepicker in the current UI Theme? I am looking to replicate the CSS properties from the datepicker for my timepicker without copying any behavioral aspects. (Although there are o ...

Ensure that the anchor element's height fills the entire div when using the display:block property

My HTML code is very simple: <div class='mydiv'> <a href='#'>Link</a> <div> As for the CSS: div.mydiv { height: 200px; width: 200px; background-color:red; } div.mydiv a { display:block; color:yellow; b ...

The importance of having separate CSS styles for various browsers, particularly when dealing with different versions of Internet Explorer like IE6, IE7, IE8, and IE9

I have always been intrigued by the fact that default CSS does not always work across all browsers, often resulting in breaks specifically for IE browsers (6, 7, 8, 9). As a result, we typically find ourselves creating multiple CSS files tailored for dif ...

Fixed-top navigation bar in Bootstrap

Currently working on constructing a Single Page Application (SPA) using Bootstrap, where the navbar is fixed-top. Encountering an issue where content gets cut off by the navbar unless setting the element margin-top to 58px. Although using the specified sty ...

Guide to comparing two TSX elements in a React + TSX environment

I am facing difficulties in comparing two React TSX elements. Despite being new to both React and TSX, I have tried copying and pasting the exact elements for comparison but it doesn't seem to work. Can you guide me on what might be causing this issue ...

Eliminating a mystery space in HTML

I am facing an issue with my website where two pages that are meant to look the same have a different appearance. One of the pages has a blank area at the top, which I would like to remove. I have tried to identify which HTML code is causing this, but so f ...

Issue with functionality of inline list menu

Having trouble with a JQ drop down menu and suspect it's an HTML/CSS issue. Spent hours tweaking it, but still not working as expected. Looking to understand the correct approach rather than just getting it to function. The slidetoggle feature is mess ...

Transitioning from Webpack version 4 to version 5 resulted in a failure to detect certain styles

After migrating my React project to Webpack v5, I am facing an issue where none of my .scss files are being picked up when I run the project. I meticulously followed the guide on migrating webpack https://webpack.js.org/migrate/5/, updated all plugins and ...

How to access a particular tab in Bootstrap 5 using an external link

Is there a way to direct users to a specific tab upon clicking a link on another page? Check out the example below: <div class="products-btn"> <a href="products.html#pills-profile">view all</a> </div> On Pro ...

Determine through code if a CSS file is being utilized

Is there a way to automate a CSS audit for file-level info without rendering the page? Could Selenium be used for this purpose? I've come across browser plugins that can help audit CSS files, but manually reviewing results for each page would be time ...

IE8 not displaying background-image in Zen Subtheme of Drupal 7

I've been struggling to get my website to display properly across all browsers. Everything looks great except for IE8 and below. I'm not sure if it's a problem with Drupal, Zen, IE, or CSS (although the CSS code seems correct). Here is the C ...

Modifying the small-dialog identifier in the Magnificent Popup

I recently encountered an issue while trying to change the ID name of the small-dialog in the Magnificent Popup JQuery Plugin. After making the necessary CSS adjustments to accommodate this change, the dialog box stopped functioning properly. I am now seek ...

Unwanted transparency issue in MaterialUI (MUI) BottomNavigation

Greetings fellow hobby developer! I recently embarked on a project using create-react-app and incorporated MUI dependencies. One feature I added was a fixed BottomNavigation, which you can view in action here. Interestingly, in CodeSandbox, the BottomNavi ...

Is it possible for Firebug to display CSS comments? This feature would greatly assist in utilizing SASS

Can Firebug display CSS comments? I'm wondering if it can help with debugging when using line numbers from SASS. I haven't been able to find any information on this feature, so any help would be greatly appreciated. ...

Using Python and BeautifulSoup to extract the values of a tags nested within multiple other tags

<a href="link" target="_blank" class="xXx text-user topic-author" sl-processed="1"> diamonds </a> My task is to extract the word 'diamonds' from the 'a' tag using BeautifulSoup. Although I have attempted various method ...

Using jQuery to retrieve the values of two distinct sliders and executing a specific mathematical operation

I have two sliders with their own values and properties: https://i.stack.imgur.com/3OZqr.gif My goal is to retrieve the values of these two sliders and calculate a result that will be displayed next to the interest label. The calculation formula is: poun ...

Tips on increasing the width of the 'select' option once the user decides to make a selection

Here's a question for you: I have a <select> box where I set the width to 120px: <select style="width: 120px"> <option>REALLY LONG TEXT, REALLY LONG TEXT, REALLY LONG TEXT</option> <option>ABC</option> < ...

Page Built with Bootstrap Showing Excessive White Space Below and Footer Misaligned

Looking for some assistance with a webpage I've been working on. Here is the page in question: I used the official static navbar example from Bootstrap as inspiration: https://getbootstrap.com/examples/navbar-static-top/ As well as the official stic ...