Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Css transition not smooth - collapse, expand menu

I have a menu set to max width and expand/collapse toggle. I use jquery toggle for this. But the transition that I used isn't working.

 .campervan-info-list {
   transition: height 1s ease;
 }

and I tried with jquery slide toggle slow. But it applies whole div.

What am I missing here?

Jsfiddle

like image 937
Janath Avatar asked Jan 16 '19 06:01

Janath


People also ask

Can you transition position in CSS?

CSS transitions provide a way to control animation speed when changing CSS properties. Instead of having property changes take effect immediately, you can cause the changes in a property to take place over a period of time.

How do you stop a transition in CSS?

To pause an element's transition, use getComputedStyle and getPropertyValue at the point in the transition you want to pause it. Then set those CSS properties of that element equal to those values you just got.

How do you change the transition direction in CSS?

The syntax of the CSS animation-direction property is: animation-direction: normal | reverse | alternate | alternate-reverse | initial | inherit; To ensure your animation works correctly and moves in the direction you want, you have to define the animation name and duration properties as well.


1 Answers

Do you want to achieve something like this?

  $('.van-page-read-more').click( function() {
    $(".campervan-info-list").animate({height: "220px"},500);
} );
.campervan-info-expand{
  height: 50px;
  overflow: hidden;
  transition: height 1s ease;
}
<div class="campervan-info-list campervan-info-expand">
  Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis feugiat, orci sed faucibus semper, ante risus auctor ligula, ultricies cursus odio nulla ac leo. Vivamus auctor volutpat porta. Morbi venenatis luctus turpis, quis laoreet ante bibendum sit amet. Aliquam vel massa sed orci gravid
  
  <br>
  
  <br>lectus id commodo. Aliquam ultricies justo et magna porttitor tincidunt. Nam ut condimentum turpis. Praesent rutrum ut turpis non finibus. In eu egestas augue, vitae viverra mi. Nunc molestie enim est, luctus volutpat ante laoreet interdum. Proin id fermentum magna. Sed semper mauris urna, non pulvinar quam rhoncus ut. Integer ultrices sodales odio vitae pharetra. Duis a enim nec velit rhoncus pharetra eu a sapien.

Donec sem enim, ornare vitae tellus eu, porta ultricies ligula. Suspendisse in nisi a metus sagittis iaculis. Nullam eu eros eu urna
<br>

lacinia lacinia. Quisque pharetra metus neque, in venenatis sem scelerisque eu. Proin blandit, purus vel volutpat scelerisque, ex orci varius nunc, ut consequat turpis mauris non magna. Mauris pellentesque mauris mi, e
</div>
<br>
<a class="van-page-read-more">Read more</a>
like image 180
m.hedayat Avatar answered Oct 19 '22 18:10

m.hedayat