How to change pages using JS keeping the navbar locked on top?

Viewed 49

.mid {
    display: block;
    width: 60%;
    margin: auto auto;
}
.navbar {
    display: inline-block;
    position: absolute;
}

.navbar li {
    display: inline-block;
    font-size: 140%;
}
 <div class="mid">
            <ul class="navbar">
                <li><a href="#">Home</a></li>
                <li><a href="#">About</a></li>
                <li><a href="/services.html">Services</a></li>
                <li><a href="#">Feedback</a></li>
                <li><a href="#">Support</a></li>
            </ul>

        </div>

I want to go to the Services pages with the navbar locked on top. If the bar is fixed on top then called page should cover the rest of the screen.

1 Answers

you can try:

.navbar {
    top: 0;
    position: fixed;
    width:100%;
}

this should hold the nav bar at the top of the page.

Related