"Front-end" JavaScript implements navigation bar spreading effects

Source: Internet
Author: User
Tags abs

Implementation results:

The implementation effect is as shown

Implementation principle:

What is a somersault cloud effect:

    • The effect is simple, that is, when you move the mouse over the other navigation directory, there will be a background image to slide to the current directory with the mouse.

Implementation ideas:

    • When the mouse passes, use offsetleft to get the distance from the left side of the current box and assign this value to the end value of the easing animation.
    • When clicked, remember the current offsetleft value, and when the mouse passes, the offsetleft of the previous click is given now.

Implementation code:

Here is the implementation code and a detailed comment, the core setting a span tag position to absolute, by binding mouse events, with the encapsulated animate animation to achieve the "wings of the Cloud" effect of span.

<! DOCTYPE html>

  

"Front-end" JavaScript implements navigation bar spreading effects

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.