简体   繁体   English

Div水平固定位置,水平滚动时垂直移动

[英]Div fixed position horizontally with vertical movement upon horizontal scroll

I am creating a website which scrolls horizontally. 我正在创建一个水平滚动的网站。 It is to depict travelling across a scene. 它描绘了穿越场景的旅行。 What I want to do is have a div containing an image of the sun to stay in the same position horizontally but move down vertically as the website is scrolled, so that at the start of the 'journey' the sun div is high in the sky and as you progress through the site the sun div 'sets' 我想做的是有一个包含太阳图像的div水平保持在同一位置,但在网站滚动时垂直向下移动,这样在“旅程”开始时太阳天空高在天空中当你在网站上前进时,sun div'sets'

I can't think of a way to do this and was hoping someone might be able to help. 我想不出办法做到这一点,并希望有人能够提供帮助。

Thanks! 谢谢!

You could try using something like .scroll() if you'r using JQuery. 如果您使用JQuery,可以尝试使用.scroll()之类的东西。

.scroll API If you look at the comments and adapt that to horizontal scrolling i think it might work. .scroll API如果您查看注释并将其调整为水平滚动,我认为它可能会起作用。

Did another search and found this as well: javascript-bind-an-event-handler-to-horizontal-scroll 做了另一次搜索并发现了这个: javascript-bind-an-event-handler-to-horizo​​ntal-scroll

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM