Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS3 Transformation blurry borders

Tags:

css

I have a centered form on my page positioned using top and left values and css3 transformations.

<div class="middle">
    <h1>This is blurry, or should be.</h1>
</div>

.middle {
    position: absolute;
    top: 50%;
    left: 50%;
    min-width: 390px;

    -webkit-transform: translate(-50%, -50%);
    transform: translate(-50%, -50%);

    /** backface-visibility: hidden; **/
}

h1 {
    padding-bottom: 5px;
    border-bottom: 3px solid blue
}

Notice backface-visibility. When set to hidden, all problems are solved for me using chrome 42. It doesn't render blurry. For others however using the same chrome version, it renders blurry with it.

Here's what it looks like without BV: http://jsfiddle.net/mzws2fnp/

enter image description here

To you it may be blurry, to others it may not.

Here's what it looks like with BV: http://jsfiddle.net/mzws2fnp/2/

enter image description here

For some reason people see the border blurry however I do not. I know backface-visibility: hidden is meant to fix that, and it does for me, just not for others using the same browser as I. Strange.

like image 303
davidxd33 Avatar asked Apr 09 '15 15:04

davidxd33


People also ask

What is border-style in CSS?

CSS Border Style The border-style property specifies what kind of border to display. The following values are allowed: dotted - Defines a dotted border

How do I Blur a background image in CSS?

If you want the blur to have a color, you’ll need to add the background property with an rgba value. Make sure that the alpha (opacity) is less than 1, so we can see through the color. Then we’ll add the magical backdrop-filter CSS property and give it a value of blur (8px). Hint, hint…increase/decrease the px to increase/decrease the blur.

Why is the border area of this image blurred?

Since this pseudo-element is only visible only underneath the partially transparent border (the rest is covered by its parent’s padding-box -restricted background ), it results the border area is the only area of the image we see blurred.

How do I change the color of a CSS border?

CSS Border Color. The border-color property is used to set the color of the four borders. The color can be set by: name - specify a color name, like "red". Hex - specify a hex value, like "#ff0000".


1 Answers

This is a bug in Google Chrome. I reported this issue to Google:

Rendering bug in css transform: it blurrs borders

<div class="middle">
    <input type="text" />
</div>
.middle {
    position: absolute;
    top: 50%;
    left: 50%;
    -webkit-transform: translateY(-50%) translateX(-50%);
    transform: translateY(-50%) translateX(-50%);
}
input {
    border: 1px solid black;
    border-radius: 4px;
}
var middle = document.querySelector('.middle');
setInterval(function(){
    middle.style.paddingTop = middle.style.paddingTop === "0px" ? "1px" : "0px";
}, 1000);

Animated bug demonstration

like image 58
user1613797 Avatar answered Oct 21 '22 23:10

user1613797