CSS Transition from height auto to height 75% [duplicate] - css

This question already has answers here:
How can I transition height: 0; to height: auto; using CSS?
(41 answers)
Closed 8 years ago.
I made a css transition which is from height auto to height: 75%.
CSS-Transition:
-webkit-transition: height 0.5s ease-in-out;
-moz-transition: height 0.5s ease-in-out;
-o-transition: height 0.5s ease-in-out;
transition: height 0.5s ease-in-out;
But its not working in IE and Firefox. I found some posts on google, but couldnt find a solution.
Thanks four your help.

To work with % and auto you can try with min-height like this:
div {
-webkit-transition: height 1s ease-in-out;
-moz-transition: all 1s ease-in-out;
-o-transition: all 1s ease-in-out;
transition: all 1s ease-in-out;
}
div:hover {
min-height:75%;
}
Check this Demo Fiddle
Tested in Chrome 31 -- Firefox 26

Try this: transition example
CSS:
.tran{
-webkit-transition: height 0.5s ease-in-out;
-moz-transition: height 0.5s ease-in-out;
-o-transition: height 0.5s ease-in-out;
transition: height 0.5s ease-in-out;
height: 100px;
background: #e5e5e5;
height: 100%;
}
.tran:hover{
height: 300px;
}
HTML:
<div style="height: 200px;">
<div class="tran">
Example
</div>
</div>

Simple, change from height to min-height or max-height, what ever will better for your needs.
Example:Fiddle

Related

CSS Transform div on not empty [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 4 years ago.
Improve this question
On my site I have an aside that lets the user perform common tasks like adding an item. There are multiple steps (pages) and I want them to appear to slide in left to right using CSS.
I have tried using the empty tag and the visiblity tag to trigger the transition but it never happens.
.slideOnVisible:empty{
height: 0px;
-webkit-transition: height 0.5s linear;
-moz-transition: height 0.5s linear;
-ms-transition: height 0.5s linear;
-o-transition: height 0.5s linear;
transition: height 0.5s linear;
}
.slideOnVisible:not(:empty){
height: 100%;
-webkit-transition: height 0.5s linear;
-moz-transition: height 0.5s linear;
-ms-transition: height 0.5s linear;
-o-transition: height 0.5s linear;
transition: height 0.5s linear;
}
I don't need to transition the height property so if there is a better way please let me know.
I am using Bootstrap, LESS and ko.js
Here is a fiddle: https://jsfiddle.net/p97wdqqm/1/
It turns out you want something like this.
var DemoModel = function() {
var self = this;
self.obsProperty = ko.observable(null);
self.toggleObsProperty = function() {
if (self.obsProperty() === null) {
self.obsProperty({
id: 1
});
} else {
self.obsProperty(null);
}
};
};
ko.applyBindings(new DemoModel());
.slideOnVisible { /* initial state */
height: 2em;
width: 0;
white-space: nowrap; /* or it would wrap during the transition */
overflow: hidden;
-webkit-transition: width 2.5s linear;
-moz-transition: width 2.5s linear;
-ms-transition: width 2.5s linear;
-o-transition: width 2.5s linear;
transition: width 2.5s linear;
}
.slideOnVisible:not(:empty) {
width: 10em;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/knockout/3.4.2/knockout-min.js"></script>
<html>
<body id="main">
<div class="slideOnVisible" data-bind="with: obsProperty">
made it
</div>
<button data-bind="click: toggleObsProperty">Toggle Property</button>
</body>
</html>

pixelated image during css transition

When the transition below occurs, the image becomes pixelated for a second or two. Do you know why it happens and how to fix it ?
#picture {
height: 96px;
width: 96px;
-webkit-transition: all 0.05s ease-out;
-moz-transition: all 0.05s ease-out;
-o-transition: all 0.05s ease-out;
transition: all 0.05s ease-out;
background-color: black;
}
#picture:hover {
height: 106px;
width: 106px;
-webkit-transition: all 0.05s ease-in;
-moz-transition: all 0.05s ease-in;
-o-transition: all 0.05s ease-in;
transition: all 0.05s ease-in;
}
<img src="http://stefandigital.com/yp/images/icons/man01.png" id="picture" />
Codepen
Instead of changing width and height properties, use transform and the scale() function.
Performance-wise, using transform will result in a better FPS because it avoids browser reflow.
#picture {
height: 96px;
width: 96px;
-webkit-transition: transform 0.05s ease-out;
-moz-transition: transform 0.05s ease-out;
-o-transition: transform 0.05s ease-out;
transition: transform 0.05s ease-out;
background-color: black;
transform-origin: 0 0;
}
#picture:hover {
transform: scale(1.141);
}
<img src="http://stefandigital.com/yp/images/icons/man01.png" id="picture" />
Revised Codepen
Notes:
Avoid using the keyword all in the transition property, targeting only the properties that are going to be transitioned helps in performance.
Unless the transition-timing-fuction changes in the hover state, the transition property does not need to be defined in the :hover pseudo-class.
transform-origin is used to change the origin of the transformation of the element.
The original images' size was way too big. It was 2000x2000 px, I brought it down to 128x128. Now the pixels are gone! But thank you guys for the optimization

css3 transform on image hover in firefox

.mark.studio{
background: url(../images/studio_icon.png) no-repeat;
-webkit-transition: all .3s ease-in-out;
-moz-transition: all .3s ease-in-out;
-ms-transition: all .3s ease-in-out;
height: 50px;
width: 50px;
z-index:103 !important;
}
.mark.studio:hover{
-webkit-transition: all .3s ease-in-out;
-moz-transition: all .3s ease-in-out;
-ms-transition: all .3s ease-in-out;
background: url(../images/studio_icon-hover.png) no-repeat;
z-index:103 !important;
}
With this css on hover the image morphs from the original image to the hover image giving a really cool effect, in firefox and IE9 I just get a hover image replacement. I put the -webkit-transition in both selectors but i'm pretty sure it only needs to be in
.mark.studio
Specify the unprefixed version of transition; Firefox and Internet Explorer dropped the prefixes. (Note that it’s Internet Explorer 10; IE9 doesn’t support transition.)
.mark.studio {
background: url(../images/studio_icon.png) no-repeat;
-webkit-transition: all .3s ease-in-out;
-moz-transition: all .3s ease-in-out;
transition: all .3s ease-in-out;
height: 50px;
width: 50px;
z-index: 103 !important;
}
.mark.studio:hover {
background-image: url(../images/studio_icon-hover.png);
}
I took the liberty of taking z-index and transition off the :hover state; it’s pointless to add them again. (Unless you have another z-index with !important that overrides it, which would be a really bad design.)
Internet Explorer 9 doesn't support the -ms-transition tag, it only works properly on Internet Explorer 10 and up. IE10 supports both.

CSS selection and effects

Heelo guys !
I need a hand with CSS.
I would like to do an effect on all the item when one of them is clicked.
#scrollBox #content .item:active (?)
{
width: 0px;
}
#scrollBox #content .item
{
width : 100%;
-webkit-transition: all 1s ease-out;
-moz-transition: all 1s ease-out;
-o-transition: all 1s ease-out;
-ms-transition: all 1s ease-out;
transition: all 1s ease-out;
}
I don't know is there is something which could replace (?) to get what I want ?
Thanks for your help !

Different css3 transition time for "into" and "return" state

I'm trying to user css3 transitions to fade the opacity of an element (http://www.w3schools.com/cssref/css3_pr_transition-duration.asp).
For instance, I say:
-webkit-transition: opacity 2s ease-in-out;
Is there a way to specify a different "return to original state" time than the 2s?
I'd like to low the opacity in 2 seconds, but bring it back up in 0.5 seconds.
CSS3 Transition: Different transition for *IN* and *OUT* (or returning from transitioned state) seems to accomplish this but using multiple elements. Any better way?
Yes, there is a better way - http://jsfiddle.net/bJKpu/
Just specify different transition-duration-s for normal and hovered state:
div {
height: 200px;
width: 200px;
background: orange;
opacity: .5;
-webkit-transition: all .5s ease-in-out;
-moz-transition: all .5s ease-in-out;
}
div:hover {
opacity: 1;
height: 300px;
width: 300px;
-webkit-transition: all 2s ease-in-out;
-moz-transition: all 2s ease-in-out;
}

Resources