Home  >  Article  >  Web Front-end  >  JS implements navigation bar hover effect (continued 2)_javascript skills

JS implements navigation bar hover effect (continued 2)_javascript skills

WBOY
WBOYOriginal
2016-05-16 17:21:311169browse

[JS-implement navigation bar hover]
[JS-implement navigation bar hover (continued)]

After rewriting this page with Jquery , found that the original method still has several problems:

1. First of all, the Js code is redundant, and the Tab on the navigation bar uses js to implement jumps instead of hyperlinks;

2 .Also the navigation bar itself is positioned with fixed, but it is not set to be horizontally centered. Instead, the left value is changed in JS to center it.

Problem 2 results in that when the size of the browser window changes, the position of the div in the browser changes, which results in the inability to dynamically fix the fixed div through the div in the page. Position the navigation bar to locate.

The final code changes are as follows:

test.html

Copy code The code is as follows: