When the navigation bar clicks the option, how can you remember the current option and at the same time realize the following line to slide past?

what you are doing now is refresh, which is the first one by default.
has tried to modify href before to remember the current option, but you can"t slide the line below the previous option.
want to know if there is any way to achieve the above two requirements or what examples you can take a look at. Thank you

Dec.07,2021

https://codeshelper.com/a/11. my example is OK, you can try to add a border to see borer-bottom


tell me about a presentation logic I implemented earlier, but the specific code was not found:

  • title list and underscore are two separate blocks. Each time the title is selected, the underline is shifted.

there are several concrete implementations as follows:
method 1 : in each title selected trigger event, through js, dynamically modify the distance of the underline and match the css3 filling animation;
method 2 : realize the underline displacement by changing the class, and match the css3 filling animation at the same time;


1. After each switch, write the corresponding title id to localstorage or cookie, to take it the next time you refresh it. The disadvantage is that even if it comes in from another interface, it will not become title 1, but the

you saved before.

2. Use history.pushState ("", ","? id= "+ id) to put the corresponding title id in the link, so that the interface will not be refreshed

Menu