423,323 Members | 1,789 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 423,323 IT Pros & Developers. It's quick & easy.

How to keep my navigation bar stick to the top?

P: 4
Im trying to get my nagivation bar to stick to the top of the page but cant for some reason. I tried looking up and i tried a few things but they didnt work.

Expand|Select|Wrap|Line Numbers
  1. body {background-color:black;}
  2.      ul {
  3.      list-style-type: none;
  4.      margin: -8;
  5.      padding-bottom: 0px;
  6.      padding-top: 0px;
  7.      overflow:hidden;
  8.      background-color:rgb(235,0,0);
  9.      margin-top: 5px;
  10.      font-family: ariel;
  11.      }
  12.     li {
  13.      padding-left: 35%;
  14.     }
  15.     li a {
  16.     display: inline;
  17.     float: left;
  18.     text-decoration: none;
  19.     padding-left: 25px;
  20.     padding-top: 20px;
  21.     padding-right: 25px;
  22.     padding-bottom: 20px;
  23.     }
  24.     li a:link{
  25.     color:white;
  26.     text-decoration: none;
  27.     }
  28.     li a:visited{
  29.     color:purple;
  30.     text-decoration: none;
  31.     }
  32.     li a:hover{
  33.     background-color:rgb(200,0,0);
  34.     text-decoration: none;
  35.     margin: auto;
  36.     }
  37.     li a:active{
  38.     color:rgb(100,100,100);
  39.     text-decoration: none;
  40.     }
As you can see i use ul,li and a href tags to make the nav bar and to get it in a horizontal form i use float: left Thanks!
Oct 9 '17 #1

✓ answered by Exequiel

just put this to your css in ul
Expand|Select|Wrap|Line Numbers
  1. position: fixed;

Share this Question
Share on Google+
2 Replies


Exequiel
100+
P: 287
just put this to your css in ul
Expand|Select|Wrap|Line Numbers
  1. position: fixed;
Oct 10 '17 #2

P: 4
Hey, thanks a lot for help :)
Oct 16 '17 #3

Post your reply

Sign in to post your reply or Sign up for a free account.