Image out of box. It seems that is not the right think I do. If anyone can help I would be glad.
Thank You!
Here You can find Demo
.box {
width:210px;
height:210px;
border-radius:50%;
border:3px solid yellow;
cursor: default;
overflow: hidden;
}
img{
overflow: hidden;
width:210px;
height:210px;
z-index:-1;
display: block;
position: relative;
-webkit-transition: all 0.6s ease-in-out;
-moz-transition: all 0.6s ease-in-out;
-o-transition: all 0.6s ease-in-out;
-ms-transition: all 0.6s ease-in-out;
transition: all 0.6s ease-in-out;
}
.box:hover img{
-webkit-transform: scale(2);
-moz-transform: scale(2);
-o-transform: scale(2);
-ms-transform: scale(2);
transform: scale(2);
}
It's seems the problem is only on webkit browsers. I make some research after catch that border-radius property crash the scale transition and I found this
overflow:hidden ignored with border-radius and CSS transforms (webkit only)
You have to put -webkit-mask-image: to the parent div to fix that.
-webkit-mask-image: -webkit-radial-gradient(circle, white, black);
http://jsfiddle.net/Jx8xF/16/
Edit: And have you attention, that background-size is expensive operation - see this article on Fix 4. Remove background-size CSS property if it slows down your website
http://kristerkari.github.io/adventures-in-webkit-land/blog/2013/08/30/fixing-a-parallax-scrolling-website-to-run-in-60-fps/
And finally you can see that zoomin the image is more smooth with scale() css transition method than background-size
EDIT2: code update on http://jsfiddle.net/Jx8xF/19/
Tested on Safari 5.1.7, Chrome, Mozilla, IE10, Opera, Opera Next
As you can see the Safari browser is only who have problems after first fix. For him you need to set
-webkit-transform: translateZ(0);
And that is not all. You need to group two layers for the border bug, and wrap it with another div. In code you can see the complete fix in HTML and CSS file.
This effect can be better achieved by removing the img element, and instead using the image as a background on the .box element. Then you use transition on the background-size property.
Here is a working example on CodePen. Example code below.
.box {
-webkit-transition: all 0.4s ease;
width:210px;
height:210px;
border-radius:100%;
border:3px solid yellow;
background: url('http://fc07.deviantart.net/fs71/f/2012/144/b/6/barn_owl_leather_mask_by_teonova_by_teonova-d50xl3v.jpg') center center;
background-size: 100%;
}
.box:hover{
-webkit-transition: all 0.4s ease;
background-size: 150%;
}
Related
When you hover over image1div, it scales to 0.95 and fades to 80% opacity. It works in Chrome and Firefox but not Safari. It fades and scales instantly in Safari rather than smoothly in 0.5s.
.image1div {
width: 350px;
height: 350px;
margin-top: 0px;
float: right;
background-color: #5a89ad;
background-size: cover;
filter:alpha(opacity=100);
-webkit-transform: scale(1,1);
-ms-transform: scale(1,1);
transform: scale(1,1);
-webkit-transition: opacity 0.5s ease, transform 0.5s ease;
transition: opacity 0.5s ease, transform 0.5s ease;
}
.image1div:not(.no-hover):hover {
-webkit-transform: scale(0.95,0.95);
-ms-transform: scale(0.95,0.95);
transform: scale(0.95,0.95);
opacity:0.8;
filter:alpha(opacity=80);
}
I think it has to do with the filter property.
Transition is supported by safari: http://caniuse.com/#feat=css-transitions
Also the filter property, but you need to add a prefix: http://caniuse.com/#feat=css-filters
Let me know if it helps, if not, provide more details and we will find a workaround.
-- EDIT
Instead of transition: opacity, transform. Use all, or check out how you can add multiple properties CSS transition shorthand with multiple properties?
I'm using ccs3 to fade in an image on hover. I'd like that same image that fades in on hover to rotate. I seem to be missing something.
Here is a jsfiddle. http://jsfiddle.net/5ftZ7/
<div id="cf">
<img class="bottom" alt="" src="http://s513195336.onlinehome.us/wp-content/uploads/2014/02/pin-over.png" /> <img class="top" alt="" src="http://s513195336.onlinehome.us/wp-content/uploads/2014/02/pin.png" />
</div>
#cf {
position:relative;
margin:30px auto;
width:200px;
height:200px;
}
#cf img {
margin-top:30px;
position:absolute;
left:0;
top:0;
-webkit-transition: opacity .2s ease-in-out;
-moz-transition: opacity .2s ease-in-out;
-o-transition: opacity .2s ease-in-out;
transition: opacity .2s ease-in-out;
-webkit-transition: -webkit-transform 0.2s ease-in;
}
#cf img.top:hover {
opacity:0;
position:absolute;
left:0;
top:0;
-ms-transform: rotate(30deg); /* IE 9 */
-webkit-transform: rotate(30deg); /* Chrome, Safari, Opera */
transform: rotate(30deg);
}
There are a variety of issues that culminate in this not working the way you want:
Understanding of transition rules
CSS properties cannot accumulate. There is nothing special about the transition rule:
transition: opacity .2s ease-in-out;
transition: transform .2s ease-in-out;
The second declaration overrides the first. This would be no different than:
color: red;
color: blue;
being blue. You can use multiple comma-separated transition definitions, or use the special all property:
transition-property: opacity, transform;
transition-duration: .2s;
transition-timing-function: ease-in-out;
/* or */
transition: opacity .2s ease-in-out, transform .2s ease-in-out;
/* or, but this may affect properties you do not want */
transition: all .2s ease-in-out
:hover with stacked elements.
.top is on top of .bottom, so .bottom cannot be hovered even when .top is transparent. This prevents rules that you would want to apply to .bottom from being applied. The simplest solution to this is just to check for :hover on #cf instead, as in #cf:hover img.top as the selector.
transform missing from .bottom
.bottom also needs the transform rules when it is hovered so it can rotate in sync with .top.
Here is a working example using only -webkit and increasing the transition durations for effect.
http://jsfiddle.net/ExplosionPIlls/5ftZ7/1/
I guess what you are trying to achieve is this:
Fiddle: http://jsfiddle.net/marionebl/5ftZ7/2/.
Includes -webkit- only for brevity. What this does:
Uses the former .bottom as first layer in stack
Replaces .bottom with a html element mimicking the image in your fiddle. Could be a png with transparency, too.
Listen for :hover state on #cf instead of .bottom or .top
Fade the former .bottom in, rotate the former .top
you can't use several transitions on an element,
if you want to apply transition to several properties you can use "all"
transition: all 1s;
or comma separated transition:
transition: opacity 1s, transform 0.8s;
#keyframes rotation {
0% {
transform: rotate(0deg);
opacity: 0;
}
100% {
transform: rotate(359deg);
opacity: 1;
}
}
i have a problem with scale transforme effect and overflow on Safari.
When i used this effect on a div content, the overflow not work on a rounded container.
here my code:
.container{
width:100px;
height:100px;
border-radius: 50%;
background:none;
z-index:100;
box-shadow:
inset 0 0 0 6px rgba(255,255,255,0.6),
0 1px 2px rgba(0,0,0,0.1);
overflow:hidden;
-webkit-transition:all .9s ease-in-out; // Chrome Safari
-moz-transition:all.9s ease-in-out; // Mozilla
-o-transition:all.9s ease-in-out; // Opéra
-ms-transition:all .9s ease-in-out; // IE
transition:all.9s ease-in-out;
}
.container:hover .scaler
{
-webkit-transform: rotate(380deg) scale(11);
-moz-transform: rotate(380deg) scale(11);
-o-transform: rotate(380deg) scale(11);
transform: rotate(380deg) scale(11);
filter: alpha(opacity=0);
opacity: 0;
width:100px;
height:100px;
border-radius: 50%;
}
.scaler{
width:100px;
height:100px;
font-size:36px;
border-radius: 50%;
z-index:-999;
line-height:100px;
vertical-align:middle;
text-align:center;
background:#0066FF;
color:#CCCCCC;
-webkit-transition:all .4s; // Chrome Safari
-moz-transition:all .4s; // Mozilla
-o-transition:all .4s; // Opéra
-ms-transition:all .4s; // IE
transition:all .4s;
}
<div class="container">
<div class="scaler">HI</div>
</div>
thank you very much!!
(sorry for my bad english)
If you include -webkit-mask-image with a radial gradient on the .container class, this will create a mask which will prevent the content of the child element being shown outside the bounds of the parent. This is much like a layer mask used in a graphics application.
-webkit-mask-image: -webkit-radial-gradient(white, black);
I used clip-path to overcome this problem, as it does exactly what you'd expect: Clips anything outside the region that it defines. And it will retain your border-radius if you use content-box as the value:
.container
{
clip-path: content-box;
}
Here's a more detailed breakdown of what you can achieve with clip-path.
Edit: Removed reference to the -webkit prefix as this isn't necessary. Also, the content-box value is only valid in Safari, but this is the only browser I saw the original problem in anyway.
I came across the transform problem in Safari, and it needs an update.
My problem had to do with a counter skewed background-image in a skewed container.
The solution with
-webkit-mask-image: -webkit-linear-gradient(white, black);
works good in Safari for OS X (11.0.1), but it breaks the anti-aliasing in Chrome (62).
Safari appears to have dropped support for
clip-path: content-box;
but not for
-webkit-clip-path: content-box;
despite the inspector claims that the -webkit- prefix is not needed.
Please test the following fiddle in Safari or Chrome as well as Firefox. You will notice that the animation is smooth in Safari, even after the mouse is no longer hovering over the div (when the div has moved past the mouse). In Firefox, however, once the div moves to where the mouse is no longer touching, it begins to move back to its original position, thus causing an unsightly shake. Can I use JavaScript to resolve this issue?
jsFiddle
#object01 {
position:relative;
margin-top:10em;
width:300px;
height:300px;
background-color:red;
border:2px solid black;
transform:rotate(5deg);
-webkit-transform:rotate(5deg);
-moz-transform:rotate(5deg);
-o-transform:rotate(5deg);
-ms-transform:rotate(5deg);
z-index:1000;
transition:all 1s ease;
-webkit-transition:all 1s ease;
-ms-transition:all 1s ease;
-moz-transition:all 1s ease;
-o-transition:all 1s ease;
top:0;
}
#object01:hover {
transform:rotate(0deg);
-webkit-transform:rotate(0deg);
-moz-transform:rotatate(0deg);
-o-transform:rotate(0deg);
-ms-transform:rotate(0deg);
top:-250px;
}
To avoid need to change the markup, you can add a pseudo-element and animate in in the opposite direction, so it will 'hold the active area' when the main element is moved:
#object01:after {
content: '';
position: absolute;
top: 0;
left: 0;
height: 100%;
width: 100%;
-webkit-transition:all 1s ease;
-moz-transition:all 1s ease;
-o-transition:all 1s ease;
transition:all 1s ease;
}
#object01:hover:after {
-webkit-transform: translateY(250px);
-moz-transform: translateY(250px);
-o-transform: translateY(250px);
-ms-transform: translateY(250px));
transform: translateY(250px);
}
(fiddle)
Also, there are several observations that animation has better performance and goes smoother if animating transform: translate(...) than if animating top/left: 1, 2. And it's better if the unprefixed property goes after the prefixed ones (because if the browser supports both prefixed and unprefixed syntax, there are more chances for the prefixed implementation to be buggy than for the unprefixed one). And there is no need to specify -ms-transition since IE9 doesn't understand it, and all shipped versions of IE10 support the unprefixed syntax.
I am trying to realise a nice Hover Off effect using CSS. There is a pretty good example here, but I can't reproduce this with the properties background-size and font-size.
The effect is simply to zoom in the image and the text on mouse over and come back to the original state on hover off but in a clean way (using -webkit-transition). This code fails:
.nice a {
background: url(../my_image.png) no-repeat;
background-size: 40px 37px;
font-size: 12px;
/* HOVER OFF */
-webkit-transition: background-size 2s;
-webkit-transition: font-size 2s;
}
.nice a:hover{
background: url(../my_image.png) no-repeat ;
background-size: 43px 39px;
font-size: 13px;
/* HOVER ON */
-webkit-transition: background-size 2s;
-webkit-transition: font-size 2s;
}
Any ideas?
I think the problem, with the code you provided, is there aren't enough 'steps' or 'keyframes' for the animation to run smoothly.
See this demo: http://dabblet.com/gist/3763579.
The box using your properties[one on the right], has 2 seconds on the clock to animate just one or two pixels, so there'd be an apparent delay before the artifacts jump to the next pixel. Same with animating back to place, hence the choppy, un-smooth transition.
You can use transform:scale(value);
Test it
.nice a {
font-size: 12px;
display:block;
-webkit-transition:all 2s ease;
-webkit-transform-origin:top left;
}
.nice a:hover {
-webkit-transform:scale(1.3);
}
Here is working Demo
and the tutorial to know more about background
This is another way to do it with transforms.
.nice a { -webkit-transition: font-size .2s ease-in-out; }
.nice a:hover { -webkit-transform: scale(1.1); }
example with key frames(drawback is not all the time hover, it won't stay).
#-webkit-keyframes scalar{
from{
background-size: 40px 37px;
font-size: 22px;
}
to{
background-size: 103px 79px;
font-size: 32px;
}
}
.nice2 a{
background: skyblue;
background-image:url("http://lorempixel.com/300/200/abstract");
background-repeat:no-repeat;
background-size: 40px 37px;
font-size: 22px;
color:white;
}
.nice2 a:hover{
-webkit-animation: scalar 1s;
}
upadated demo with keyframes
we have seen Three ways to do it. lets decide which best for it.
Transitions which gives smooth and nice appearance.
Transforms which blurs while growing content.
Keyframes which leads to high end but...
Choice is yours!
My bad, this works:
/* HOVER OFF */
-webkit-transition-property: background-size, font-size;
o-transition-property: background-size, font-size;
-moz-transition-property: background-size, font-size;
transition-property: background-size, font-size;
-webkit-transition-duration: 0.5s;
-o-transition-duration: 0.5s;
-moz-transition-duration: 0.5s;
transition-duration: 0.5s;