M
M
Michael R.2018-03-27 14:26:12
css
Michael R., 2018-03-27 14:26:12

How to make a smooth change in height?

Hello!
There is a block with elements:

<div class="wrapper">
  <div class="item">item</div>
  <div class="item">item</div>
  <div class="item">item</div>
  <div class="item">item</div>
</div>

Now when you add a new itemheight wrappersharply adjusts to the content.
Question: how to make a smooth increase / decrease in height wrapperwhen the content changes in it?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
H
hardcorelite, 2018-03-27
@Mike_Ro

<div class="wrapper">
  <div class="item">item</div>
  <div class="item">item</div>
  <div class="item">item</div>
  <div class="item">item</div>
</div>
        <a id="clickme" href="#">click</a>

.wrapper {
    margin:20px;
    background-color:#fff;
    padding:15px;
}

.bubble{
    animation: animateElement linear .3s;
    animation-iteration-count: 1;
    background:#e7e7e7;
    margin-bottom:5px;
    width:100%;
    min-height:30px;
    border-radius:10px;
}

@keyframes animateElement{
    0% {
        opacity:0;
        transform:  translate(0px,10px);
    }
    100% {
        opacity:1;
        transform:  translate(0px,0px);
    }
}

$('#clickme').click(function() {
                    var newElement = $('<div class="item">item</div>');
                    $('.wrapper').append(newElement);
        });

M
Maxim Timofeev, 2018-03-27
@webinar

Make the new item's margin-top equal to the height, smoothly remove to 0.

K
Kirill Gorelov, 2018-03-27
@Kirill-Gorelov

api.jquery.com/animate
_

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question