Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Css transition div shaking

Tags:

html

css

Why when I use position absolute and percentage width I have this glitch when I hover on div above? There is example. I have this glitch on little more complicated site.

<div class="box"> text </div>

<div class="container">


<div>

.box {
    width: 50%;
    height: 50%;
    background: red;
}
.box:hover {
    transition: 0.5s;
    -webkit-transform: translate(0, 6px);

}
.container {
    position:absolute;
    top:40px;
    width:40%;
    height:50px;
    float:left;
    background: blue;
    color:white;
}

http://jsfiddle.net/TsUEH/

When you hover on red text then width of blue div are shaking. How can i avoid this without removing percentage and position absolute?

like image 490
NahKolor Avatar asked Mar 15 '14 11:03

NahKolor


People also ask

How do you shake text in HTML?

CSS Code: In this section first we will design the text with some basic CSS and use @keyframes animation and then use the transitionX() function to produce the shaking effect when we hover over the text.

What triggers CSS transition?

Transition triggers # Your CSS must include a change of state and an event that triggers that state change for CSS transitions to activate. A typical example of such a trigger is the :hover pseudo-class. This pseudo-class matches when the user hovers over an element with their cursor.

How do you shake an image in HTML?

Simply replace . shake:hover with .

How do you make a transition smooth in CSS?

With CSS you can make it smooth without any extra effort. Add a transition to the element and any change will happen smoothly:.ball { border-radius: 25px; width: 50px; height: 50px; background: #c00; position: absolute; top: 0; left: 0; transition: transform 1s; } Detecting the start and completion of a transition

What are CSS transitions?

CSS transitions allows you to change property values smoothly, over a given duration. Mouse over the element below to see a CSS transition effect:

How do I create a transition effect in HTML?

To create a transition effect, you must specify two things: Note: If the duration part is not specified, the transition will have no effect, because the default value is 0. The following example shows a 100px * 100px red <div> element. The <div> element has also specified a transition effect for the width property, with a duration of 2 seconds:

What is the transition time for the <div> element?

The <div> element has also specified a transition effect for the width property, with a duration of 2 seconds: Example. div {. width: 100px; height: 100px; background: red; transition: width 2s; }. The transition effect will start when the specified CSS property (width) changes value.


1 Answers

It works fine for me, but if you find an element "shaking" (esp in Chrome), it's likely because of the translate function not working with the z-index correctly

If you need to fix it, you can use this code (lifesaver):

-webkit-backface-visibility: hidden;
-webkit-transform: translateZ(0) scale(1.0, 1.0);
like image 94
Richard Peck Avatar answered Sep 24 '22 23:09

Richard Peck