Scroll element to top of window

Is there a way to do this? I have tried scrollto but not quite right. Basically when someone onkeypress an element i want it to the top of the viewport, mainly on mobile so the keyboard doesnt block the elwmwnt and dropdown i have.

Thanks guys

Hi,
Why scrollTo doesn’t suits your needs? Moreover, note that in case you wish to write the code for mobile site, you would need to use the Wix Window API to check whether the site visitor uses a mobile device or a desktop.

Best,
Tal.

Is there a scroll to top code or Something? I’m just not sure of the syntax to achieve this?

Tal if you could assist?

Hi,
Firstly, note that you can simply use the Back to Top button . Another option is using the scrollTo function. In order to know what are the X & Y positions, you can use the editor toolbar .

Best,
Tal.

All good thanks Tal

1 Like

Old post, but thought would ask…

I need to be able to scroll to a position which the coordinates are set based on the opening browser viewport. I cannot get the coordinates from editor toolbar because they will not be correct.

Is there a way we can write to the console.log coordinates of an element?

Cheers,

Calum

Old post from 2018 being closed.
Please refer to it with a link in a new post if you still require help.