I
I
Ivan Erokhin2018-02-13 22:42:51
css
Ivan Erokhin, 2018-02-13 22:42:51

How to animate a block shift when a block appears nearby?

There is a block (display:table-cell;vertical-align:middle;) which is located inside a block with display: table;

When you click on the button inside the block, a block of text appears below (display:none -> display:block), the block on top is shifted from the center to the top of the page. Together with the text, they remain centered.

JQUERY code

$('.more1').click(function(){
  $('.mt1').toggleClass('open', 500, "easeOutSine"); //класс на кнопке
  $('.more_text1').addClass('animated slideInUp'); //анимация появления текста (animated.css)
  $('.more_text1').fadeToggle(500);	//появление блока текстового
});


For example, here is something similar https://codepen.io/anon/pen/BYdLMq . When you press the button, the button expands instantly, how is it done smoothly?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
M
maxsnw, 2018-02-14
@maxsnw

remember that through css animation plus block\non display, the transition will not work, it will only work with caution. Through the script it is possible to set a smooth appearance, but it also, as far as I know, does not work very well.
$(".element").fadeOut(300, function(){$(this).removeClass("open", 300)});

D
Dima, 2018-02-13
Dolgoter @DDolgy

Transition width 0.5s linear

K
kally, 2018-02-13
@kally

.gallery{
        width: 100px;				
        opacity: 0;
        transition: all 2s;	/*  all-что именно меняется, 2s-скорость в секундах  */	
}

.gallery-1{
        width: 300px;				
        opacity: 0;	
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question