Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Css -webkit-backface-visibility shows white dots on rotated div

Tags:

html

css

I have a DIV and it is rotated by:

transform: rotate(-5deg);
-ms-transform: rotate(-5deg);
-webkit-transform: rotate(-5deg);

It's good there, but when I add

-webkit-backface-visibility: hidden;

It shos these white dots..

Any ideas? - thanks!

enter image description here

DEMO: http://jsfiddle.net/X5WKM/

like image 534
Peter Avatar asked May 16 '13 21:05

Peter


People also ask

What is rotateX?

rotateX() The rotateX() CSS function defines a transformation that rotates an element around the abscissa (horizontal axis) without deforming it. Its result is a <transform-function> data type.

How do you rotate a div in CSS?

rotate() The rotate() CSS function defines a transformation that rotates an element around a fixed point on the 2D plane, without deforming it. Its result is a <transform-function> data type.

How do I rotate a Div 90 degrees?

An element can be rotated 90 degrees by using the transform property. This property is used to move, rotate, scale and others to perform various kinds of transformation to elements. The rotate() transformation function can be used as the value to rotate the element.


1 Answers

You're already well aware that the dots are caused by the -webkit-backface-visibility property. This appears to be a bug in Chrome v26- which, as NOX commented, appears to have been fixed in v27 (just checked this myself, the issue is still present in v27 on Windows 7).

The simple quick fix for this involves replacing:

* {
    margin:0;
    padding:0;
    transform: translate3d(0,0,0);
}

With:

* {
    margin:0;
    padding:0;
    transform: translate3d(0,0,0);
}

#nav, #topp, #footer {
    -webkit-backface-visibility: hidden;
}

This simply removes the -webkit-backface-visibility property from your #top and #foo elements - which doesn't appear to cause any harm.

Here is a JSFiddle example of this where I've made the background of the header and footer black to make it easier to see that the dots are no longer there at all.


As a side note, you should always put vendor prefixes before the real CSS properties. Instead of putting -ms-transform and -webkit-transform after transform, you should put them before:

-ms-transform: rotate(-5deg);
-webkit-transform: rotate(-5deg);
transform: rotate(-5deg);
like image 119
James Donnelly Avatar answered Sep 17 '22 03:09

James Donnelly