<!doctype html>
<meta charset= "UTF-8" >
<meta http-equiv= "x-ua-compatible" content= "Ie=edge" >
<title>untitled document</title>
<meta name= "description" content= "" >
<meta name= "viewport" content= "Width=device-width, initial-scale=1" >
<link rel= "Apple-touch-icon" href= "Apple-touch-icon.png" >
<!--place Favicon.ico in the root directory--
<link rel= "stylesheet" type= "Text/css" href= "Style.css" >
<script src= "Jquery-1.11.3.js" ></script>
<script>
$ (function () {
$ (' Nav ul Li '). MouseEnter (function () {
var _left=$ (this). Position (). Left;
var _width=$ (this). Width () +40;
$ ('. NAV-BG '). CSS ("left", _left);
$ ('. NAV-BG '). CSS ("width", _width);
});
$ (' nav '). MouseLeave (function () {
var _left=$ (' Nav ul Li.on '). Position (). Left;
var _width=$ (' Nav ul li.on '). Width () +40;
$ ('. NAV-BG '). CSS ("left", _left);
$ ('. NAV-BG '). CSS ("width", _width);
})
})
</script>
<style>
body,html,ul{margin:0px;padding:0px;}
A{text-decoration:none;}
Header{width:100%;height:40px;background: #ddd; line-height:40px;}
Nav{width:1200px;margin:auto;position:relative;}
Nav ul {Position:relative;z-index:1;overflow:hidden;}
Nav ul li{width:auto;padding:0px 20px; float:left;list-style:none;cursor:pointer;text-align:center;height:40px; line-height:40px;}
. Nav-bg{height:40px;background: #333;p osition:absolute;left:0px;opacity:0.2;transition-duration:. 5s;z-index:0;}
</style>
<body>
<nav>
<div class= "NAV-BG" ></div>
<ul>
<li class= "on" ><a href= "#" > column title </a></li>
<li><a href= "#" > column title </a></li>
<li><a href= "#" > column title </a></li>
<li><a href= "#" > column title </a></li>
</ul>
</nav>
</body>
Navigation bar Background Move