1
Good evening! I am making an application and need to use some slide effects. I used the animate
jquery to get the desired result.
It was even good, but while the animation occurs the height of the div increases/ decreases so that all the text inside fits, follows the example:
$('#btnprincipal').click(function (){
$('#divTexto').animate({ width: 'toggle' }, 500);
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<button id="btnprincipal">Aperte aqui</button>
<div id="divTexto" style="background-color:#00ff00">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam ultricies erat massa, sed posuere risus pharetra sed. Integer in pretium tortor. Sed vestibulum orci ut odio lacinia fermentum. Ut nec nulla sed ligula finibus volutpat vel nec sem. Nulla aliquam mauris vel tortor sodales, id finibus est varius. Duis suscipit ultrices dolor, vitae molestie ex fringilla vitae. Suspendisse et sapien eu orci egestas volutpat quis vitae mauris. Curabitur nisl risus, maximus ac tristique sed, consequat quis risus. Nunc vel venenatis mi, eu faucibus arcu. Nunc quis faucibus sem. Vestibulum dignissim commodo lectus, sit amet iaculis metus lacinia ac. Integer placerat faucibus metus et consequat. Aliquam sed volutpat justo, vel pharetra nunc.</div>
What can I do to prevent this behavior?
if the
height
do div this should not happen, for exampleheight: 200px
– Ricardo Pontual
I deleted my answer, now that I see the accepted answer I understand the purpose of the question :)
– LeAndrade
Yes, but I couldn’t set height because the text was generated according to what the user typed into what I did. The accepted answer gave the solution to the problem
– Vitor Ceolin