DEV Community

Basha
Basha

Posted on

Sticky nav bar

Hey:)

You can easily make your nav bar sticky at the top
Html:

<!DOCTYPE html>
<html lang=”en”>
<head>
    <meta charset=”UTF-8″>
    <meta http-equiv=”X-UA-Compatible” content=”IE=edge”>
    <meta name=”viewport” content=”width=device-width, initial-scale=1.0″>
    <link rel=”stylesheet” href=”style.css”>
    <title>Sticky</title>
</head>
<body>
    <nav id=”nav”><h1>Content</h1></nav>
</body>
</html>
Enter fullscreen mode Exit fullscreen mode

CSS:

#nav{

    position:sticky;

    top:0;

    left:0;

}
Enter fullscreen mode Exit fullscreen mode

Top comments (0)