Bizarre glitch in the box-shadow transition

Recently, I encountered an unusual issue involving transitioning a box-shadow...

Upon hovering over the divs, a box-shadow (black, 5px spread) is applied with a transition. Once the cursor leaves the divs, the box-shadow spread returns to 0px.

The strange part: when the div is displayed with a percentage-based positioning (e.g. left: 1%), the box-shadow does not clear properly. Some remnants remain visible - see red divs in the JSFiddle link.

It gets even weirder: the leftover box-shadow's position and shape vary. It appears to be somehow linked to the screen width. Just resize the browser window in the JSFiddle link and hover again...

Here's the JSFiddle for reference

CSS

.a, .b, .c, .d {
    margin: 5px;
    width: 100px;
    height: 100px;
    transition: box-shadow 0.2s linear;
    box-shadow: 0 0 0 0 black;
    position: relative;
}
.a, .b {
    background-color: #6c6;
}
.c, .d {
    background-color: #c66;
}
.b {
    left: 50px;
}
.c {
    left: 1%;
}
.d {
    left: 2%;
}
.a:hover, .b:hover, .c:hover, .d:hover {
    box-shadow: 0 0 0 5px black;
}

HTML

<div class="a"></div>
<div class="b"></div>
<div class="c"></div>
<div class="d"></div>

Is there something I'm overlooking here or is this possibly a bug?

PS: This behavior seems to occur in Chrome and Opera, but Firefox does not exhibit this issue.

Answer №1

One way to resolve the issue is by including transform: translate3d(0,0,0); in the element's code. This strategy, known as the null transform hack, can make the bug disappear.

Check out this JSFiddle for a demonstration

Answer №2

I encountered a similar issue and came across a solution provided by @fcalderan's null transform hack.

It is worth noting that this issue should have been resolved with the release of Chrome 67, although it worked without any intervention in the past. After researching chrome issues, I found that it was a known issue which has been addressed.

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

Developing Wordpress themes with varying H5 tag sizes across different pages

I'm struggling with a puzzling issue while developing a Wordpress theme. When I zoom in to 250% on mobile, all the header text stays the same size on every page except for one. On that particular page, the text appears significantly larger, almost as ...

Is it possible to combine and compress HTML/CSS/JS files using npm?

When organizing my CSS code and directory folders, I like to use multiple stylesheets to keep things tidy. However, it appears that @import is not recommended in CSS. Instead, combining your code (as @import does) and minifying it by removing comments, spa ...

"PHP's isset function causes an infinite hang when trying to set a radio

When processing each question <input> set, some questions have radio button answers while others have checkboxes... Upon submitting, the data is inserted into the database $i = 1; while($i<6){ if(isset($_POST['radio' . $i])){ (MY ...

Image failed to load

Issue Encountered in Browser Console: https://static.food2fork.com/pastaallavodkaa870.jpg.jpg 404 While attempting to display the image on the browser, I am uncertain if the problem lies within my code or with food2fork. Code from index.js: // Alway ...

Send a list of integers created in a JavaScript function from a Razor view to a controller

Is it possible to transfer data from JS created select tags to the controller? Here is the function responsible for generating the select tags: function changeFunc() { var elements = document.getElementsByClassName('selector2'); while (el ...

Making an Axios request with parameters

I am facing an issue where my parameter articleid is not being passed to the route /createAnswer. When I log articleData._id, it shows the correct ID (e.g., 60b4f5d8c8be1d4cb0cdd6ca) that I want to pass to the route /createAnswer. const createAnswer = () = ...

Concealing an Automatically Updated Section when Devoid of Content -- Ruby on Rails Version 4

I have come across various solutions to this problem, but none of them seem to be effective for my specific project. In my application, the user's previous choices are displayed in multiple divs. Initially, all the divs are empty. As the user progress ...

Bring NavLinks from a separate class into the NavBar Class in a React application

Hello! I am new to React and I am currently working on creating a navbar component using materialize css. I have separate classes for loggedinlinks and loggedoutlinks, but when I include them in my Navbar class and run the application, the links are not ap ...

Customizing the appearance of Twitter Bootstrap based on the AngularJS input class $invalid

I'm struggling with getting error messages to display properly in my Bootstrap form when using AngularJS. I followed the instructions on this link: but I still can't figure out what I'm doing wrong. Any advice? Thanks <div class=" ...

challenges encountered with the clearTimeout() method in vue.js

I am currently working on implementing a shopping cart using Vue, but I am encountering some challenges. As I am new to using this library, it is possible that I am making some basic mistakes. Here is the issue I am facing: When I add an item to the cart, ...

Mandating the inclusion of a directives controller in conjunction with other necessary controllers

Two directives are nested within each other, with one requiring the other using require: '^parentTag' . Both directives have their own controllers. In the parent directive, I can access its controller as the fourth argument in link: function(scop ...

Creating a grid pattern of boxes within a rectangle using CSS

I'm attempting to design a rectangle filled with colorful boxes Here is the code I'm using: <div class="col-md-3" > <div id="myViewport" style="height: 700px; width: 50px; padding: 10px; border: 5px solid gray; margin: 0;"> ...

react-bootstrap-table - multiColumnSearch - Requesting data from two columns rather than requiring a match in both

I want to enhance the search functionality in react-bootstrap-table multiColumnSearch by requiring data from two or more columns instead of matching all data in the table. For instance: ID FAMILY YEAR --------------------- 1 FAMILY-1 2010 2 ...

Joining two tables with MongoDB and Node.js API: Step-by-step guide

Just started exploring node.js and mongodb and managed to create an API with the help of Google. Successfully implemented CRUD operations on a single table using MongoDB + Node.js. However, faced with the challenge of joining tables in node.js. request. ...

Ensure the unordered list (ul) remains fixed in place

Is there a way to make my left menu, which is a ul, stay static on the screen so that the full menu always appears when I scroll? I attempted to set 'position: fixed; top: 0, left: 0' but it caused the div next to the ul to shift on top of the u ...

Difficulty resizing background image on iPhone

I am having an issue with the background image resizing correctly on my website, specifically on iPhone (I have not yet checked iPad). You can view the site here. The dimensions of the image are 1393 x 1098 pixels. Below is the CSS code I am currently us ...

Ways to retrieve a returned value from mongoose

I am attempting to retrieve a value from a mongoose callback function, but I keep encountering an error stating TypeError: #<Object> is not a function. I understand that it may be tricky to achieve this, but the way I am querying the database require ...

"Learn the process of transferring a JavaScript variable to a Flask Jinja function using the url_for

$("#getVerification").click(function () { var phoneNumber=$("#cellphone").val(); console.log(phoneNumber); $.getJSON("{{ url_for('auth.sendsms', cellphone=phoneNumber )}}", function(data){ }); }); Looking at the code abov ...

The IsArray() function in IE8 encounters an issue where it expects an error object

I am interested to know why IE8 is having trouble with this line of code: if (isArray(obj)) When I check in the IE8 javascript console, I see the following: >>obj {...} >>typeof(obj) "object" >>Object.prototype.toString.call(obj) "[obj ...

How to customize the text color of the notchedOutline span in Material UI

I'm currently working on customizing the textfield in materialUI. This is what I am trying to modify. I am facing challenges in changing the color of the span tag that contains the text, and also in maintaining the border color when the textfield is ...