Pure CSS Solution - Flexbox Ordering
html , , dom, input - 1- html, 2- . Flexbox order .
.
.container {
display: flex;
flex-direction: column;
}
input {
display: flex;
flex-direction: column;
order: 2;
}
.brandHeader {
display: flex;
order: 1;
transition: all 0.2s ease;
}
input:focus + .brandHeader {
margin-top: -10px;
}
<form class="container">
<input type="text" id="search-bar" placeholder="Search">
<div class="brandHeader">
<h1>My Header</h1>
</div>
</form>
Hide result
https://jsfiddle.net/Hastig/djj01x6e/
, , .
2- CSS- - :
, , order: x;
.container {
display: flex;
flex-direction: column-reverse;
}
input {
display: flex;
flex-direction: column;
}
.brandHeader {
display: flex;
transition: all 0.2s ease;
}
input:focus + .brandHeader {
margin-top: -10px;
}
<form class="container">
<input type="text" id="search-bar" placeholder="Search">
<div class="brandHeader">
<h1>My Header</h1>
</div>
</form>
Hide result
https://jsfiddle.net/Hastig/djj01x6e/1/
Flexbox, : , 1 dom, 2- , , html.