<! DOCTYPE html>
<meta charset= "UTF-8" >
<script src= "Js/jquery-1.9.1.min.js" type= "Text/javascript" charset= "Utf-8" ></script>
<title> Small slider navigation bar </title>
<style type= "Text/css" >
*{
margin:0;
padding:0;
}
. ulbox{
position:relative;
Clear:both;
}
. nav{
height:30px;
line-height:30px;
}
. Nav li{
List-style:none;
Display:block;
Float:left;
}
. Nav Li a{
Display:block;
Background-color: #000;
Text-decoration:none;
Color: #FFFFFF;
border-radius:5px;
}
span{
Position:absolute;
bottom:0;
Display:block;
height:3px;
Background-color: #FF6600;
}
</style>
<body>
<div class= "Ulbox" >
<ul class= "NAV" >
<li><a href= "#" > Navigation </a></li>
<li><a href= "#" > Navigation two </a></li>
<li><a href= "#" > Navigation three </a></li>
<li><a href= "#" > Navigation four </a></li>
<li><a href= "#" > Navigation five </a></li>
<li><a href= "#" > Navigation six </a></li>
<li><a href= "#" > Navigation VII </a></li>
</ul>
<span class= "line" ></span>
</div>
</body>
<script type= "Text/javascript" >
$ (function () {
$ ('. Ulbox. Nav li '). Hover (function () {
var width=$ (this). Outerwidth (true);//Gets the width of the current Li
var left=$ (this). Offset (). Left; Gets the left value of the current Li
$ (". Line").-Stop (true). Animate ({' Left ': Left, ' width ': width},300);//Add a slide effect to the span tag
},function () {
$ (". Line"). Animate ({' Left ': ' 0 ', ' width ': ' 0 '},1000); Animation when mouse moves out of Li
});
})
. Stop (), stop the current animation, continue to the next animation, when the mouse moves hover, the animation and display is not synchronized, the display does not reach the expected results.
. Stop (true); Clears all animations of the element, stops in the current state
. Stop (false,true); Let the current animation go directly to the end state and continue to the next animation
. Stop (true,true); Clears all animations of the element so that the current animation reaches the end state directly
</script>
jquery version Slider navigation bar