I'm having an issue in chrome with a css3 transform rotate transition. The transition is working fine but just after it finishes the element shifts by a pixel. The other strange thing is that it only happens when the page is centered (margin:0 auto;). The bug is still there if you remove the transition as well.
You can see it happening here:
http://jsfiddle.net/MfUMd/1/
HTML:
<div class="wrap">
<img src="https://github.com/favicon.ico" class="target" alt="img"/>
</div>
<div class="wrap">
<div class="block"></div>
</div>
CSS:
.wrap {
margin:50px auto;
width: 100px;
}
.block {
width:30px;
height:30px;
background:black;
}
.target,.block {
display:block;
-webkit-transition: all 0.4s ease;
-moz-transition: all 0.4s ease;
-o-transition: all 0.4s ease;
transition: all 0.4s ease;
}
.target:hover,.block:hover {
-webkit-transform: rotate(90deg);
-moz-transform: rotate(90deg);
-o-transform: rotate(90deg);
-ms-transform: rotate(90deg);
}
Comment out the margin:0 auto; line to make it go away.
Anyone have any ideas of how to stop this while keeping the page centered?
I'm using Version 24.0.1312.57 on OSX 10.6.8
Cheers
Actually just add this to the site container which holds all the elements:
-webkit-backface-visibility: hidden;
Should fix it!
Gino
I had the same issue, I fixed it by adding the following to the css of the div that is using the transition:
-webkit-backface-visibility: hidden;
-webkit-transform: translateZ(0) scale(1.0, 1.0);
Backface is used for 3D-based transitions but if you are only using 2D there is no need for the extra stuff.
will-change: transform; on the element helped to me in 2022 (Chrome). No more 1px shift of the text inside the element after zoom animation.
there is something unusual in the relation between the body dimension and the structure of the transform. I don't in fact is because the fiddle iframe that contains the preview of the code.
Anyway, I will suggest this approach instead:
body{
width:100%;
float:left;
}
.wrap {
margin: 50px 45%;
width: 5%;
float: left;
}
.block {
width:30px;
height:30px;
background:black;
}
.target,.block {
-webkit-transition: all 0.4s ease;
-moz-transition: all 0.4s ease;
-o-transition: all 0.4s ease;
transition: all 0.4s ease;
}
.target:hover,.block:hover {
-webkit-transform: rotate(90deg);
-moz-transform: rotate(90deg);
-o-transform: rotate(90deg);
-ms-transform: rotate(90deg);
}
Here is the updated fiddle
For 3d transform use this instead:
-webkit-transform: perspective(1px) scale3d(1.1, 1.1, 1);
transform: perspective(1px) scale3d(1.1, 1.1, 1);
Related
If i have some block with CSS tranformation transition and it has child with longer transition duration and other transform property text in the main block is blured till the child animation ends. Is there some way around it? Even when the other seperate block has its animation it blures the text, is there some way to seperate this effects?
.parent {
margin:10px;
width: 100px;
height: 100px;
background: #000;
color: #aabb00;
-webkit-transition: all 0.5s;
-moz-transition: all 0.5s;
-ms-transition: all 0.5s;
-o-transition: all 0.5s;
transition: all 0.5s;
}
.parent:hover {
-webkit-transform: scale(1.05);
-moz-transform: scale(1.05) ;
-ms-transform: scale(1.05) ;
-o-transform: scale(1.05) ;
transform: scale(1.05) ;
}
.parent:hover .child {
-webkit-transform: rotate(360deg);
-moz-transform: rotate(360deg) ;
-ms-transform: rotate(360deg) ;
-o-transform: rotate(360deg) ;
transform: rotate(360deg) ;
}
.child {
width: 10px;
height: 10px;
background: #fff;
-webkit-transition: all 1.5s;
-moz-transition: all 1.5s;
-ms-transition: all 1.5s;
-o-transition: all 1.5s;
transition: all 1.5s;
}
<div class="parent">
<div>
<div class="child"></div>
</div>
<div>1234123412</div>
</div>
<div class="parent">
<div>
<div></div>
</div>
<div>1234123412</div>
</div>
Actually its standard browser behavior to blur text on its resize, it comes from optimization easeus, to render new text not in every animation frame, but after animation ends. It cant be fixed.
I'm using this image zoom transition when i hover over an image. It's seems to work perfectly sometimes and sometimes it moves a little bit after zooming. I just can't figure out why..
Can anyone help me out why this happens
header {
width: 65.277777777777778%;
max-width: 1400px;
margin: 0 auto;
overflow: auto;
margin-bottom: 6%;
}
.container {
position: relative;
overflow: hidden;
/* height: 200px;
width: 200px; */
width: 100%;
}
.container img {
position: relative;
height: 100%;
width: 100%;
-webkit-transform: scale(1);
transform: scale(1);
-webkit-transition: transform;
transition: transform;
-webkit-transition-duration: 1s;
transition-duration: 1s;
display: flex;
}
.container:hover img {
-webkit-transform: scale(1.5);
transform: scale(1.5);
-webkit-transition: transform;
transition: transform;
-webkit-transition-duration: 1s;
transition-duration: 1s;
}
<header>
<div class="container">
<img src="https://pixabay.com/static/uploads/photo/2016/08/11/08/43/potatoes-1585060__340.jpg" alt="" />
</div>
</header>
Give this a try and see if it's more consistent for you. It works well for me, and I haven't noticed any issues in the months it's been implemented:
.container img {
-webkit-transition: all 1s ease-in-out;
-moz-transition: all 1s ease-in-out;
-ms-transition: all 1s ease-in-out;
-o-transition: all 1s ease-in-out;
transition: all 1s ease-in-out;
}
.container img:hover {
-webkit-transform: scale(1.5);
-moz-transform: scale(1.5);
-ms-transform: scale(1.5);
-o-transform: scale(1.5);
transform: scale(1.5);
}
See if this does the trick, if it's something you're interested in. Either way, let me know!
I am trying to fix an element to the right side of the page, rotate it 90 degrees using the transform rotate CSS property, then on hover I want the element to slide out to the left using a slow transition. However, there is an unsightly vibrating top border when I try a basic implementation of this in Chrome.
Bug Demo Page
The issue only seems to happen when text is entered in the element, and only happens when the element is dynamically sized with that text. This leads me to believe the transform property is rounding up-and-down by a pixel during the hover transition, resulting in the element to resize erratically during ease transition.
I can work around this issue by setting a fixed width on the element, but fixing the width of the element is not an acceptable solution in this case because the text can vary within this fixed element.
Does anyone have ideas for preventing or working around this issue? Thank you!
HTML
<a id="right_fixed_element">
Fixed Side Button
</a>
CSS
#right_fixed_element {
/* vibrating border bug goes away with fixed width */
/* width: 150px; */
position: fixed;
top: 40%;
right: 0;
padding: 10px;
color: white;
background-color: red;
border: 1px solid #777;
transform: rotate(-90deg);
-ms-transform: rotate(-90deg);
-webkit-transform: rotate(-90deg);
-moz-transform: rotate(-90deg);
transition: all .5s ease;
-moz-transition: all .5s ease;
-webkit-transition: all .5s ease;
-o-transition: all .5s ease;
-webkit-backface-visibility: hidden;
-webkit-transform: rotate(-90deg) translateZ(0) scale(1.0, 1.0);
}
#right_fixed_element:hover {
right: 10px;
}
I believe the animation is little cleaner using transform: translateY() to move the element (instead of animating right: 10px):
#right_fixed_element {
/* vibrating border bug goes away with fixed width */
/* width: 150px; */
position: fixed;
top: 40%;
right: 0;
padding: 10px;
color: white;
background-color: red;
border: 1px solid #777;
transform: rotate(-90deg);
-ms-transform: rotate(-90deg);
-webkit-transform: rotate(-90deg);
-moz-transform: rotate(-90deg);
transition: all .5s ease;
-moz-transition: all .5s ease;
-webkit-transition: all .5s ease;
-o-transition: all .5s ease;
-webkit-backface-visibility: hidden;
}
#right_fixed_element:hover {
transform: rotate(-90deg) translateY(-10px);
-ms-transform: rotate(-90deg) translateY(-10px);
-moz-transform: rotate(-90deg) translateY(-10px);
-webkit-transform: rotate(-90deg) translateY(-10px);
}
<!-- When you hover over this transform-rotated element with the slow transition speed, a buggy vibrating behavior appears at the top of the element.
If you set a fixed width on the element, then the vibrating behavior will go away.
How can we prevent the vibrating bug, without setting a fixed width, while still acheiving the transform on this fixed element?
-->
<a id="right_fixed_element">
Fixed Side Button
</a>
I'm making a hover effect on my website, where you hover images (pngs) and they grow in size. The problem i have is that they now get blurry when they resize.
The code that I'm using looks something like this:
.div {
-webkit-transition: -webkit-transform 0.35s;
transition: transform 0.35s;
-webkit-transform: perspective(1000px) translate3d(0,0,1px);
transform: perspective(1000px) translate3d(0,0,0);
}
.div:hover {
-webkit-transform: perspective(100px) translate3d(0,0,1px);
transform: perspective(100px) translate3d(0,0,31px);
}
And you can see the effect on this jsfiddle: enter link description here
Is there a way to fix this?
I think scale would be more appropriate for this. This solution only blurs during scaling.
.square {
width:100px;
height: 100px;
background-color:black;
margin: 50px;
}
p {
color:white;
text-align: center;
padding-top: 35px;
}
.square {
-webkit-transition: -moz-transform .3s ease-out;
-moz-transition: -webkit-transform .3s ease-out;
-o-transition: -o-transform .3s ease-out;
transition: transform .3s ease-out;
}
.square:hover {
-webkit-transform: scale(2);
-moz-transform: scale(2);
-o-transform: scale(2);
transform: scale(2);
}
<div class="square">
<p>Some text</p>
</div>
I am having a problem with given below code
This is my stylesheet
.h_w:hover img{
-webkit-transform: scale(1.1);
-moz-transform: scale(1.1);
-ms-transform: scale(1.1);
-o-transform: scale(1.1);
transform: scale(1.1);
-webkit-transition: 5s all;
-moz-transition: 5s all;
-o-transition: 5s all;
-ms-transition: 5s all;
transition: 5s all;
}
.h_w{ border-radius:200px;
-moz-border-radius: 200px;
-ms-border-radius: 200px;
-o-border-radius: 200px;
-webkit-border-radius: 200px;
height: 287px;
overflow: hidden;
position: relative;
width: 287px;
background-color: #FFFFFF;
}
.opacity-0.5{opacity:0.2;}
.circle_background{
background:url(../images/circle-bg.png) no-repeat;
height:100%;
width:100%;
position:absolute;
font-size:15px;
opacity:1 !important;
top: 286px;
}
.h_w:hover .circle_background{
transition:1s all;
-moz-transition:1s all;
-ms-transition:1s all;
-o-transition:1s all;
-webkit-transition:1s all;
top:0px;
z-index:1000px;
}
And this is my HTML
<body style="background-color: #000000;">
<div class="h_w">
<span><img src="images/projects/circles/background.png" alt="flick the switch" /></span>
</div>
</body>
This code is working fine in Mozilla firefox but in chrome it is not working when zooming it is going outside the circle.
Any help will be appreciated.
Look here for your answer: --->X<---
PS: you must add -webkit-mask-image: -webkit-radial-gradient(circle, white, black); to your img's parent-div styles.
Hope it helps.
Use this code it will work .
.h_w:hover img{
-webkit-transform: scale(1.1);
-moz-transform: scale(1.1);
-ms-transform: scale(1.1);
-o-transform: scale(1.1);
transform: scale(1.1);
-webkit-transition: 5s img ;
-moz-transition: 5s img ;
-o-transition: 5s img ;
-ms-transition: 5s img ;
transition: 5s img ;
}
here above you can see that .h_w:hover img rule uses transtion property.
In transtion property I use img because You would like to create a motion on "img" not "all" property
So use "img" instead of "all".
Hope the answer!