Reputation: 289
For structural reasons I must use absolute positioning + translateY(-50%) to vertically align elements.
However animating these vertically aligned elements shows a glitch on every browser. Elements blur during and flickering at the end of animations.
I've already tried using perspective, translateZ, rotateZ but no luck..
You can see the issue in the attached snippet
#wrapper {
background: orange;
position: relative;
width: 350px;
height: 150px;
font-family: sans-serif;
}
#elem {
transition: all 500ms ease 0ms;
transform: translate3d(-50%, -50%, 0);
position: absolute;
top: 50%;
left: 50%;
text-align: center;
width: 80%;
height: auto;
line-height: 30px;
background: teal;
color: white;
-webkit-backface-visibility: hidden;
backface-visibility: hidden;
-webkit-transform-style: preserve-3d;
transform-style: preserve-3d;
-webkit-font-smoothing: antialiased;
-webkit-perspective: 1000px;
perspective: 1000px;
}
#wrapper:hover #elem {
transform: translate3d(-50%, -50%, 0) scale(1.3);
}
<div id="wrapper">
<div id="elem">Lorem Ipsum dolor</div>
</div>
Upvotes: 1
Views: 534
Reputation: 780
Try to use em positioning technique instead of transform. It seems that transform: translate() wa causing problems with rendering.
#wrapper {
font-size:15px;
background: orange;
position: relative;
width: 300px;
height: 150px;
font-family: sans-serif;
box-sizing:border-box;
}
#elem {
transition: all 500ms ease 0ms;
position: absolute;
top: 50%;
left: 0;
display:block;
text-align: center;
width: 80%;
margin: -1em 10% 0;
height: auto;
line-height: 2em;
background: teal;
color: white;
}
#wrapper:hover #elem {
font-size:1.3em
}
<div id="wrapper">
<div id="elem">Lorem Ipsum dolor</div>
</div>
Upvotes: 1