S
S
solo_832020-04-22 17:53:59
css
solo_83, 2020-04-22 17:53:59

How to rearrange header elements on page scroll?

Hello friends!

There is a hat. There is an upper part with a logo, a city selection, a phone number and a call order button.
Below is the menu.
5ea05896d32c4886018918.jpeg

When scrolling, the header should look like this
5ea05a0c60a47500133548.jpeg

. Is it possible to do without duplicating the logo and the phone?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander Sharomet, 2020-04-22
@solo_83

You need some kind of sticky js plugin or something similar .
For example, stickyjs.com
When scrolling, add a class to your header and hang the necessary styles on it

$("#sticker").sticky({
topSpacing:0,
className: 'sticky-header' //ваш класс
});

D
dimirsh1, 2020-04-23
@dimirsh1

See.
Make a function

$('body, html').scroll((function(){
if($('body, html').scrollTop()>200) {
   $('.header').addClass('scroll');
} else {
   $('.header').removeClass('scroll');
}
});

Write css in which the scroll class will change the styles of the header.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question