Answer the question
In order to leave comments, you need to log in
Compact header of the site, how to return to its previous form?
There is a header:
<div class="head"></div>
.head {
top: 0;
width: 100%;
height: 200px;
background: blue;
position: fixed;
}
$(document).ready(function() {
$(window).scroll(function() {
$('.head').animate({
height: "100px",
}, 500);
});
});
Answer the question
In order to leave comments, you need to log in
Design in js is bad manners. Similar things are done by adding/removing classes with the desired properties.
$(window).scroll(function() {
var top = $(window).scrollTop();
if(top>0){
$('.header').addClass('header--min');
} else {
$('.header').removeClass('header--min');
}
});
.header--min{}
state changes as a class.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question