Skip to content
Advertisement

How to add a transition to a Read more code

I am pretty new to CSS & javascript. For the last 3 hours I’ve been trying to add a transition to this code. It is a ‘Read more’ function.

I hope that not only someone can finally help me with adding the transition to it, but I could learn something about CSS and javascript 🙂

JavaScript
JavaScript
JavaScript

I tried adding .card { transition: max-height 0.7s;} to the CSS.

Advertisement

Answer

There’s a lot of not “great” or simple options for this. If you use a library/framework like jquery or bootstrap they offer utilities to manage sliding size transitions for you.

This is because to do it right you need to use js to figure out and adjust the height values.

A less robust way is to do so with max-height and a transition on it. The trick is you cannot transition from something like display:none; or visibility:hidden;

JavaScript
JavaScript
JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement