M
M
mletov2020-06-15 17:01:38
css
mletov, 2020-06-15 17:01:38

Are there Media queries for scroll position?

I had a chance to see TK on the frontend in one office here.

You need to make a simple layout.
At the very top is a horizontal menu, below it is a header, then content. When scrolling down, when the menu is no longer visible, it should appear under the header, and then a simple position:fixed/sticky.

With the help of JS, this task is solved once or twice. But to the TK, a note that it is very desirable to do everything in pure CSS, without JS.

That is, in fact, you need something like a Media query, only with an analysis of the scrolling position. Although there may be other solutions.

Everything I googled - solutions with JS are everywhere, options for working with CSS with scrolling are also not rich.
I wanted to know if this is real?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
D
Dima Pautov, 2020-06-15
@bootd

No it doesn't exist

Q
qqFE, 2020-06-15
@qqFE

There are definitely no media queries, but
if you speak English, then you should read:
https://css-tricks.com/indicating-scroll-position-...

F
forspamonly2, 2020-06-16
@forspamonly2

well, if you need it on the instructions purely on css, then you can simply duplicate the menu. one menu nailed to the top of the window with a fixed, on top of it (with a larger z-index) a cap with an absolute, in it the second menu. when the header scrolls up, a second menu will peek out from under it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question