I try to get a slide effect with angular and ngAnimate.
I works nicely as a fade-in/fade-out effect with opacity.
.show-animation {
-webkit-transition: 1s all linear;
transition:all linear 1s;
opacity: 1;
}
.show-animation.ng-hide {
opacity: 0;
}
See example: https://jsfiddle.net/1bnpqpy8/10/
But when I try to use the max-height attribute for a slide effect it does not work anymore.
.show-animation {
-webkit-transition: 1s all linear;
transition:all linear 1s;
max-height: 25px;
}
.show-animation.ng-hide {
max-height: 0;
}
See example: https://jsfiddle.net/1bnpqpy8/11/
Why does ngAnimate not work with max-height?
What do I do wrong?
You are missing an important css property: overflow.
overflow tells a div what to do if the contents are greater than height (or max-height). The default value is visible and since one of your inner divs has a set height (timelineVoid set to 20px), this will force the div to be visible.
You need overflow (specifically overflow-y) set to hidden in your show-anomation div to allow content to be hidden:
overflow-y: hidden;
here is the fiddle: https://jsfiddle.net/5mr8azvn/
Related
I've got this code...
<img class="logo" src="img/logo.jpg"> <!-- Logo size is 96x96 -->
...and this
.logo {
transition: .5s;
}
.logo:hover {
transition: .5s;
width: 128px;
height: 128px;
}
It resizes on hovering, but not with transitioning. I just hover it and it instantly resizes, and I have no idea why does transition not work.
There are several things wrong with the CSS causing it not to transition.
First, as #WaisKamal said, you need to set initial states to transition from. Images size automatically in HTML but that's not a valid starting point for CSS.
Second, you need to define WHAT properties are being transitioned.
So you would need to add width and height. Or you can use the all identifier:
.logo {
display:block; //make sure the image is a block element
width: 96px;
height: 96px;
transition: all 0.5s linear;
}
.logo:hover {
width: 128px;
height: 128px;
}
Now that will work but it's going to be kind of janky since animating height/width cause page repaints.
Instead, I would suggest using a transform on the image.
.logo {
display:block; //make sure the image is a block element
// initial size is fine here because we're using a transform
transition: transform 0.5s ease-in-out;
}
.logo:hover {
transform: scale(2) // decimal notation 2 = 200% = 128x128px
}
There is no need to define the same transition property for the image and the hover pseudoclass. If you don't define transition in .logo:hover, it will take the previously set value of half a second.
The problem here is that you must specify an initial width and height for the image in order to have it resize smoothly.
Here's the html simplified sample
<div class="big">
<a href=".....">
<img src=".....">
</a>
</div>
css
.big {
width: 33.3333%;
}
img:hover {
opacity: 0.9;
transition: opacity 0.4s;
}
When I hover above img, the opacity transition works fine, but the image flickering on span 0.4s, it's like resizing, like the Chrome recalculate the percentage size again within 0.4s.
Tried webkit transition, not fixing anything. Transition all, still happening.
This problem only happen on Chrome, no problem at all on Firefox.
Only happen when using percentage, with fixed width works fine, but I need to use percentage on this one.
Thanks for any help
You can try this:
a {display: block }
a img {transition: opacity 0.4s; max-width: 100%;}
a:hover img {opacity: 0.9}
This is what fixed it for me:
max-width: calc(100% - 1px);
max-height I could leave at 100%; even though it was the height that was changing.
I've got (hopefully) a simple CSS problem, that I cannot get working.
If you go to http://new.therepairshack.com and take a look at the top search bar.
When you hover over it, it resizes to content width.
The CSS for this is here:
.header .search-wrapper .form-search .input-text {
background:rgba(0,0,0,0);
color:#000;
border-radius:0px;
border-bottom:1px solid #444;
}
.header .search-wrapper:hover,
.header .search-wrapper:hover .form-search,
.header .search-wrapper:hover form,
.header .search-wrapper:hover .input-text {
width:100%;
font-size:45px;
height:100px;
}
.header .search-wrapper,
.header .search-wrapper form,
.header .search-wrapper .form-search,
.header .search-wrapper .input-text {
transition: all 1.0s ease;
-webkit-transition: all 1.0s ease;
display:block;
}
Right now we're working on getting this functionality working in Chrome and Firefox. When I view it in chrome the background div instantly jumps to a larger height to fit the resized search bar, but when it resizes back down after you've left hover it does it smoothly.
My question: Is there any way to make the jumping go away? It's driving me nuts. I have added a transition to all of the elements that are moving when the search bar is being resized and that isn't working.
Also, what is the best way to get this working properly in other browsers? Thanks!!!
Let me know if you need anymore information!
It can't transition from an undefined starting point.
You must either
Specify an initial height on your .search-wrapper
http://jsfiddle.net/5h69j6uq/
Or, if your content must be dynamically sized, set the updated height by using the min-height: 100px property rather than the height: 100px property. min-height has a default value of 0 and will thus transition from that defined default value to 100px
http://jsfiddle.net/8t1beeLo/
You will have to manually set the height on the .header-top-container class and adjust it accordingly for the hover state.
CSS by standard will only apply animations to elements that are defined in rules to have them applied. And furthermore transitions will only be applied when there is a starting and end result, so inferred values such as height and width will not be animateable. Noticed I didn't say inherited values, as those technically have a starting value and therefore are animateable.
So for your CSS, you'll want something to this effect:
.header-top-container {
transition: height 1.0s ease;
-webkit-transition: height 1.0s ease;
height: 50px; /* change to whatever your height should be */
}
.header-top-container:hover {
height: 100px; /* the new height of the background */
}
Is it possible to trigger an animation with an another animation in CSS3 ? Or is it possible to make one animation to start just after when an another animation is finished ? I know it is possible with java script,but i want to know if it can be achieved with pure css3 ?
You can use transition-delay in conjunction with transition.
In my Snippet, the transition style causes div to change from:
Red to green in 1s.
100px to 250px width in 2s.
100px to 150px height in 1s.
The transition-delay style causes:
The first animation to occur immediately (background).
The second animation to occur after 1s (width).
The third animation to occur after 3s (height).
The end result is that each animation follows on the heels of the previous animation.
Snippet
div {
transition: background 1s, width 2s, height 1s;
transition-delay: 0s, 1s, 3s;
background: red;
width: 100px;
height: 100px;
border: 1px solid black;
}
div:hover {
background: green;
width: 250px;
height: 150px;
}
<div>
</div>
I have a hidden list on a page (opacity:0;visibility:hidden;) that is currently necessary for my menu.
My problem is that even though the z-index of the drop down part of the menu is -1 and the z-index of the content div is 50, the text inside of the content div only draws to the right of the menu. The css style display:none is not an option due to horrible resizing of elements that I don't want to deal with. Many Google and Stack Overflow searches produced no helpful results.
I have tried a variety of display settings including inline, float:left, and others that may have fixed the problem, but they didn't.
JSFiddle here which clearly defines the problem (try the second menu to see the cutoff point):
http://jsfiddle.net/nimsson/311g9h16/5/
I would like to know either
a) the reason behind this functionality
b) a workaround / solution
or both.
Thanks,
nimsson
Simply workaround You have here: http://jsfiddle.net/311g9h16/6/
I've just change #content {position: absolute} but why display: none is not an option?? Resizing should be no problem when You set height of dropdown.
Moreover, You can do this effect with some CSS - take a look: http://www.cssterm.com/css-menus/horizontal-css-menu/simple-drop-down-menu
try this: http://jsfiddle.net/311g9h16/7/
all I did was changing the way you use positioning and adjust the width to get the text to align left.
For info on position properties go here: http://www.w3schools.com/cssref/pr_class_position.asp
#content {
background-color: rgba(204,0,0,0.4);
border: 5px solid rgba(204,51,0,1);
border-radius: 10px;
position: absolute;
bottom: 500px;
color: white;
text-align: left;
width: 500px;
z-index: 50;
-webkit-transition: opacity 0.5s ease-in-out;
-moz-transition: opacity 0.5s ease-in-out;
-ms-transition: opacity 0.5s ease-in-out;
-o-transition: opacity 0.5s ease-in-out;
transition: opacity 0.5s ease-in-out;
}
You could add another div around the #content and re-set the page for the containing divs,
<div id="background">
.... </div>
css
#background{
z-index:-1;
position: absolute;
width:100%;
height:100%;
}