当前位置:网站首页>Visual rolling [contrast beauty]

Visual rolling [contrast beauty]

2020-11-06 21:07:15 itread01

![](https://img2020.cnblogs.com/blog/1308525/202011/1308525-20201106171550872-1552437424.png) # The popular science Parallax scrolling is simply to move the scroll bar or scroll the mouse wheel ,dom The difference in the speed of box movement, plus or minus, results in different effects on the page It's a sense of contrast , For programmers who don't have the ability to design aesthetically , Only write portable demo, Form your own aesthetic cultivation `codepen` It seems that we need ** Rich and strong **, I'll sort it out the day after tomorrow , Put on Baidu cloud demo Links can be downloaded I'd like to introduce you to one thing , Equivalent to zero configuration webpack, Namely `parceljs` Put in the website `https://parceljs.org/getting_started.html` It's also very easy to use ```js npm install -g parcel-bundler yarn init -y parcel index.html ``` I think YouTube This is how you use it , Then tell me why I use scss, Because what we want to write is portable demo, Written as scss perhaps less Easy to adjust , The directory structure is clearer # file https://github.com/locomotivemtl/locomotive-scroll | Properties | describe | | ---------------------------------------------------------- | ---------------------- | | data-scroll-container | Defining containers | | data-scroll | Check whether it is in the field of vision | | data-scroll-speed="number" | Element parallax velocity , Negative inversion | | data-scroll-target="#xxx" | The location of the target element in the view | | data-scroll-directio n="vertical vertical \| horizontal level " | The direction of parallax | | | | ```js import LocomotiveScroll from 'locomotive-scroll'; const scroll = new LocomotiveScroll({ el: document.querySelector('[data-scroll-container]'), smooth: true,// Whether it's smooth rolling // multiplier:10 // The speed of rolling }); ``` # Write parallax scrolling effects [ Case website ](https://tympanus.net/Development/TileScroll/) Write a prototype ```html
``` ![](https://img2020.cnblogs.com/blog/1308525/202011/1308525-20201105162548213-790697576.png) There is a visual difference in the picture Write a very low Version of ```js
``` In fact, my goal is to make you understand the most rudimentary code , To achieve the purpose of the effect ![](https://img2020.cnblogs.com/blog/1308525/202011/1308525-20201105162621139-304607781.gif) Put a css Basic issues , It's mainly because I seldom write like this ```css transform: translate(-50%,-50%) rotate(22.5deg); Vertical center Tilt 22.4 degree ``` ## Case a On the full version of the code , On the basis of the big guy, it's abbreviated , The purpose is to use and modify it later , Ha ha ha So learn one thing at a time , So it took a little bit longer ![](https://img2020.cnblogs.com/blog/1308525/202011/1308525-20201105163156193-473132075.gif) ## Case 2 ![](https://img2020.cnblogs.com/blog/1308525/202011/1308525-20201105163605746-946794281.gif) Then we can speed him up , Write a horizontal scroll with the font ## Case three ![](https://img2020.cnblogs.com/blog/1308525/202011/1308525-20201105163827982-436521225.gif) ## Case four ![](https://img2020.cnblogs.com/blog/1308525/202011/1308525-20201105164628530-2100723946.gif) ## Case 5 ![](https://img2020.cnblogs.com/blog/1308525/202011/1308525-20201105165016465-1226539148.gif) # deme6 ![](https://img2020.cnblogs.com/blog/1308525/202011/1308525-20201106163644310-1921902154.gif) ## Case seven ![](https://img2020.cnblogs.com/blog/1308525/202011/1308525-20201106165323190-877821587.gif) Put it on demo Baidu cloud ```js Link to : https://pan.baidu.com/s/1hCeY6BiRuosDGJR2rb-M1g Extraction code : 3m

版权声明
本文为[itread01]所创,转载请带上原文链接,感谢