I see a white line between skewed HTML divs on Chrome browser. Below is a screenshot of the issue:
Here's the code :
.abc {
-webkit-backface-visibility: hidden;
-moz-backface-visibility: hidden;
backface-visibility: hidden;
width: 200px;
height: 200px;
background: green;
position: absolute;
left:0px;
transform: skewX(-10deg);
transform-origin: 0% 100%;
}
.def {
-webkit-backface-visibility: hidden;
-moz-backface-visibility: hidden;
backface-visibility: hidden;
width: 200px;
height: 200px;
background: green;
position: absolute;
left:200px;
transform: skewX(-10deg);
transform-origin: 0% 100%;
}
A debug sample is available at : https://jsbin.com/dijazit/2/edit?html,css,output
How do we remove this white line? Appreciate any help here.
The skew() function is an inbuilt function which is used to transform an element in the 2D plane. Skew an element means to pick a point and push or pull it in different directions. Parameters: ax: This parameter holds the angle representing the horizontal axis to distort an element.
The skew() function is specified with either one or two values, which represent the amount of skewing to be applied in each direction. If you only specify one value it is used for the x-axis and there will be no skewing on the y-axis.
The skew() function accepts two arguments, indicating the angle of the skew for the x and y axes respectively. These are represented by angle values. If only one value is supplied, the second value has a zero value.
This is kind of a known issue with respect to rendering transformed elements in Chrome. What makes it more weird is the fact that we come across many similar issues and each time the fix applied for the previous (very similar) case ends up not working for the current one.
For this particular scenario, adding a transparent 1 pixel border around the elements seems to fix it.
.abc {
position: absolute;
left: 0px;
width: 200px;
height: 200px;
background: green;
transform-origin: 0% 100%;
transform: skewX(-10deg);
border: 1px solid transparent;
}
.def {
position: absolute;
left: 200px;
width: 200px;
height: 200px;
background: green;
transform-origin: 0% 100%;
transform: skewX(-10deg);
border: 1px solid transparent;
}
<div class="abc"></div>
<div class="def"></div>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With