Centering example div in div with animation
by greatCar
HTML
Centering example:
<div id="container">
<div id="content">
Line 1
</div>
</div>
CSS
body {
font: 36px Arial, sans-serif;
}
#container {
color: white;
background: #ffbd17;
width: 400px;
height: 260px;
display: flex;
justify-content: center;
align-items: center;
}
#content {
background: #06c;
flex: 0 0 120px; /*ok to remove to shrink wrap whatevern that means
https://stackoverflow.com/questions/5703552/how-can-i-center-text-horizontally-and-vertically-inside-a-div-block/*
}
JavaScript
(function() {
var toggle = true;
setInterval(function() {
if (toggle) {
$("#content").html("Line 1");
} else {
$("#content").html("<div>Line 1</div><div>Line 2</div>");
}
toggle = !toggle;
}, 1300);
}());