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?
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.
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.
Simply replace . shake:hover with .
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
CSS transitions allows you to change property values smoothly, over a given duration. Mouse over the element below to see a CSS transition effect:
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:
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.
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);
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