Home  >  Article  >  Web Front-end  >  JavaScript implements personalized navigation bar special effects

JavaScript implements personalized navigation bar special effects

php中世界最好的语言
php中世界最好的语言Original
2017-12-31 11:36:322340browse

What we bring to you this time is JavaScript to implement personalized navigation bar special effects. We know that the omnipotent JS can achieve many special effects. This article will give you a detailed analysis.

Implementation principle:

What is the somersault cloud effect:

•This effect is very simple, that is, when the mouse moves to other navigation directories, a background image will follow the mouse and slide to the current one. 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. By binding the mouse event, the encapsulated animate animation is used to realize the "somersault" of the span. "Cloud" effect.




  导航栏筋斗云效果
  
  

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

I believe you have mastered the method after reading the above introduction. For more exciting information, please pay attention to other related articles on the php Chinese website!

Related reading:

How to use vue to implement login verification

Use jQuery to deduplicate and sort arrays Operation

How to determine whether the CheckBox selected is empty

The above is the detailed content of JavaScript implements personalized navigation bar special effects. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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