Home > Web Front-end > JS Tutorial > body text

Sample code for implementing exquisite personalized navigation bar somersault cloud effect using JavaScript

黄舟
Release: 2017-10-30 09:23:52
Original
2009 people have browsed it

Achievement effect:

Implementation effect is shown in the figure below

##Implementation principle:

What is the somersault cloud effect:

•This effect is very simple, that is, when the mouse is moved to other navigation directories, the background image will slide with the mouse to the current directory.

Implementation ideas:

•When the mouse passes by, use offsetLeft to get the distance from the current box to the left, and assign this value to the end value of the easing animation.

•When you click, remember the current offsetLeft value. When the mouse passes by, give the previously clicked offsetLeft the value when it passes now.

Implementation code:

The following is the implementation code and detailed comments. The core is to set a span tag with position absolute, bind the mouse event, and use the encapsulated animate Animation realizes span's "somersault cloud" effect.




  导航栏筋斗云效果
  
  

  • 菜单栏1
  • 菜单栏2
  • 菜单栏3
  • 菜单栏4
  • 菜单栏5

Copy after login

Summary

The above is the detailed content of Sample code for implementing exquisite personalized navigation bar somersault cloud effect using JavaScript. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!