When you create a one page website, the section goes scroll around the page.
but you need to make a menu active for every section you click.
Let’s say we have 4 section. Home, Features, Colors and Price.
Home section is already on active mode when we load the page.
HTML
<div class="menu-top"> <ul> <li><a class="active" href="#home">Home</a></li> <li><a href="#features">features</a></li> <li><a href="#colors">colors</a></li> <li><a href="#price">price</a></li> </ul> </div>
CSS
.menu-top ul, .menu-top li { list-style: none; display: inline; margin: 0; padding: 0; } .menu-top li a { color: #666666; float: left; text-decoration: none; text-transform: capitalize; font-family:"Montserrat", "Helvetica Neue", Arial, Helvetica, sans-serif; font-weight: 700; font-size:14px; margin-right: 1px; padding: 7px 10px; text-align: center; letter-spacing: -1px; } .menu-top li a:hover, .menu-top li a.active { color: #FFFFFF; background: #029ecf; text-decoration: none; -webkit-border-radius: 3px; -moz-border-radius: 3px; border-radius: 3px; text-shadow:0 1px 0 #111; }
Features is active when it clicked
Jquery
<script type="text/javascript"> $(document).ready(function(){ //active link clicked $(".menu-top ul li a").click(function() { $(".menu-top ul li a").removeClass("active"); $(this).addClass("active"); }); }); </script>
You should load the Jquery Library first.
With this code above, the menu you clicked will get class=”active” meanwhile the others menu will remove the class=”active”